<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ogremindes.net &#187; oop</title>
	<atom:link href="http://ogremindes.net/tag/oop/feed/" rel="self" type="application/rss+xml" />
	<link>http://ogremindes.net</link>
	<description></description>
	<lastBuildDate>Thu, 18 Feb 2010 21:41:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.3</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Introduction To Programming: Object Orientated Programming Principles</title>
		<link>http://ogremindes.net/blog/introduction-to-programming-object-orientated-programming-principles/</link>
		<comments>http://ogremindes.net/blog/introduction-to-programming-object-orientated-programming-principles/#comments</comments>
		<pubDate>Tue, 30 May 2006 01:37:58 +0000</pubDate>
		<dc:creator>Ogremindes</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[TAFE]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[oop]]></category>

		<guid isPermaLink="false">http://ogremindes.net/introduction-to-programming-object-orientated-programming-principles/</guid>
		<description><![CDATA[Although I didn&#8217;t know it at the time, my first exposure to OOP was with TADS, a language for developing text-based adventure games...]]></description>
			<content:encoded><![CDATA[<p>Although I didn&#8217;t know it at the time, my first exposure to <acronym title="Object Orientated Programming">OOP</acronym> was with <acronym title="Text Adventure Development System"><a href="http://www.tads.org/" onclick="javascript:urchinTracker ('/outbound/article/www.tads.org');">TADS</a></acronym>, a language for developing text-based adventure games. I didn&#8217;t stick with <acronym title="Text Adventure Development System"><a href="http://www.tads.org/" onclick="javascript:urchinTracker ('/outbound/article/www.tads.org');">TADS</a></acronym> for very long, just for a few weeks between finishing year 12 and getting a copy of <a href="http://www.blizzard.com/diablo2/" onclick="javascript:urchinTracker ('/outbound/article/www.blizzard.com');">Diablo II</a></p>
<p>Object Orientated Programming (<acronym title="Object Orientated Programming">OOP</acronym>) is programming by referring to, well, <em>things</em>.</p>
<p>In regular(linear) programming everything that the program does is laid out by the programmer. In <acronym title="Object Orientated Programming">OOP</acronym>, we have use of <em>objects</em>: self-contained collections of data and instructions.</p>
<p>So, while in linear programming if we wanted to know the length of a string we&#8217;d have to construct a loop to count through each of the letters, in <acronym title="Object Orientated Programming">OOP</acronym> we could call up the &#8216;length&#8217; property of the already-defined string object. The code for counting the letters still exists, but it is inside the string object and the programmer never needs to know how it gets the number. All the programmer needs to know is an what properties an object has, and what it can do: its methods.</p>
<h3>What are Properties and Methods? What&#8217;s the difference?</h3>
<p>The properties of an object are information about it: the colour of a paint or the date of a diary entry would be considered properties of those things. Conversely methods are the things that an object can do: a car can accelerate, an alarm bell can ring.</p>
<p>Let us take, for the purpose of example, a printer:<br />
<img src="http://ogremindes.net/wp-content/uploads/2006/05/lexmark-e321-laser-printer.thumbnail.jpg" alt="lexmark-e321-laser-printer.jpg"></p>
<ul>
<li>
<h4>Properties</h4>
</li>
<li>Paper Left</li>
<li>Ready Status</li>
<li>Power Status (on/off)</li>
<li>Ink Level</li>
</ul>
<ul>
<li>
<h4>Methods</h4>
</li>
<li>Print Single Sided</li>
<li>Print Double Sided</li>
</ul>
<h3>The Dot Syntax</h3>
<p>In many object orientated programming languages the <em>dot syntax</em> is used for referring to objects and their properties and methods. To take the example above, the syntax to refer to the &#8216;Paper Left&#8217; property would be <code>printer.paperLeft</code>. The syntax for telling it to print a document single-sided would be <code>printer.printSingleSided(myDocument)</code>, where myDocument is the document to be printed. Methods always have a pair of brackets at the end, if the method needs information to work then that information is but inside the brackets.</p>
<h3>JavaScript Objects</h3>
<p>JavaScript is an object orientated language, with its own collection of objects. It also uses the <acronym title="Document Object Model">DOM</acronym> to access objects within HTML files.</p>
<p>The variable is one of the most common JavaScript objects. For a variable containing a string called <var>myString</var>, containing the word &#8220;script&#8221; there would be properties such as <code>myString.value</code>, which would be &#8220;script&#8221;, and <code>myString.length</code>, which would be 6. Methods for myString would include <code>toUpperCase()</code>, which converts the letters all to uppercase, and <code>indexOf()</code>, which would give the position of a given letter in the string.</p>
<p>The &#8220;text&#8221; object corresponds to a HTML <code></code>. Properties include <code>disabled</code>, which will either be true, in which case the input is disabled, or false, where the input can be activated, and <code>defaultValue</code>, which is the default text in the input. Methods include <code>focus()</code>, which puts the curser in the input, and <code>blur()</code>, which removes the curser from the input.</p>
<p>The &#8220;image&#8221; object corresponds to a HTML <code>&lt;img /&gt;</code> element. Properties include &#8220;src&#8221;, the source file of the image, &#8220;width&#8221; and &#8220;hight&#8221;. Methods include <code>click()</code>, which has the effect of clicking on the image (for the purposes of an <code>onClick()</code> event, for example).</p>
]]></content:encoded>
			<wfw:commentRss>http://ogremindes.net/blog/introduction-to-programming-object-orientated-programming-principles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

