<?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>My Mind Leaks &#187; object oriented programming</title>
	<atom:link href="http://www.mymindleaks.com/blog/archives/tag/object-oriented-programming/feed" rel="self" type="application/rss+xml" />
	<link>http://www.mymindleaks.com/blog</link>
	<description>Software, Programming, Architecture &#38; More</description>
	<lastBuildDate>Sun, 11 Jul 2010 05:06:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Object Oriented Programming – Encapsulation is not just hiding data!</title>
		<link>http://www.mymindleaks.com/blog/archives/object-oriented-programming-%e2%80%93-encapsulation-is-not-just-hiding-data.html</link>
		<comments>http://www.mymindleaks.com/blog/archives/object-oriented-programming-%e2%80%93-encapsulation-is-not-just-hiding-data.html#comments</comments>
		<pubDate>Mon, 09 Jun 2008 09:15:43 +0000</pubDate>
		<dc:creator>Maheshwaran Subramaniya</dc:creator>
				<category><![CDATA[Articles on Computer Science]]></category>
		<category><![CDATA[Encapsulation]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[object oriented programming]]></category>
		<category><![CDATA[Resources]]></category>

		<guid isPermaLink="false">http://mymindleaks.com/?p=655</guid>
		<description><![CDATA[Continuing the Object Oriented Programming series, after writing about Abstraction, it&#8217;s time to educate about Encapsulation. Let&#8217;s first look at what is generally believed as Encapsulation? Ask your teacher, &#8220;What is Encapsulation?&#8221; You teacher would promptly say &#8220;Hiding data&#8220;. Try googling, you find just 10% of the sites will be giving you right information about [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing the <a href="http://mymindleaks.com/tag/object-oriented-programming/">Object Oriented Programming</a> series, after writing about <a href="http://mymindleaks.com/programming/object-oriented-programming-abstraction/">Abstraction</a>, it&#8217;s time to educate about Encapsulation.</p>
<p>Let&#8217;s first look at what is generally believed as Encapsulation? Ask your teacher, &#8220;What is Encapsulation?&#8221; You teacher would promptly say &#8220;<strong>Hiding data</strong>&#8220;. Try googling, you find just 10% of the sites will be giving you right information about Encapsulation where most of them tends to miss out the important glitch. When one of my friends was speaking about Encapsulation, he was right in quoting the proper definition i.e. &#8220;Hiding Information&#8221;, but his understanding was not correct. If you are one of them who doesn&#8217;t understand about Encapsulation, then this article is for you.<span id="more-655"></span></p>
<p>So, what exactly the encapsulation means bro? Ok. Let we have some coffee, and we continue discuss about Encapsulation.</p>
<p style="text-align: center"><img src="http://mymindleaks.com/wp-content/uploads/2008/06/060908-0915-objectorien12.jpg" alt="060908 0915 objectorien12 Object Oriented Programming – Encapsulation is not just hiding data!"  title="Object Oriented Programming – Encapsulation is not just hiding data!" /></p>
<p>Cool, the coffee vending machine has given tasty brewed coffees. Nice coffee! Back to our discussion, here is a simple question I&#8217;d like to ask you. Why don&#8217;t you give a thought on how did this coffee vending machine worked?</p>
<p>You dropped in the coin, and the coffee came out of the machine in a beautiful coffee cup. So, why didn&#8217;t you see how the where the coffee beans, how it is prepared? You really don&#8217;t know (unless you are the one who designed the machine <img src='http://www.mymindleaks.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' title="Object Oriented Programming – Encapsulation is not just hiding data!" /> ) how things are made inside the machine, but finally you get a coffee!! Yeah don&#8217;t you see a sense of Encapsulation? So, here what is actually hidden? The Coffee beans? <strong><em>No, the way how the coffee prepared is hidden</em></strong>.</p>
<p><strong>So, Encapsulation is hiding of process; hence you hide the data. Not the vice versa.<br />
</strong></p>
<p>From the definition, <strong>Encapsulation is &#8220;Information Hiding&#8221;</strong>, the information is how <strong>something is happening</strong> inside an object? It&#8217;s just a mere <strong>data hiding concept </strong>(though it includes data hiding).</p>
<p>So, when you model this coffee vending machine, you don&#8217;t want to show out the way how a coffee is made. Isn&#8217;t it? So, you don&#8217;t want to show where the coffee beans, milk and the sugar are. Right?</p>
<p style="text-align: center"><img src="http://mymindleaks.com/wp-content/uploads/2008/06/060908-0915-objectorien22.png" alt="060908 0915 objectorien22 Object Oriented Programming – Encapsulation is not just hiding data!"  title="Object Oriented Programming – Encapsulation is not just hiding data!" /></p>
<p>So, in the CofeeVendingMachine class, prepareCoffee() is hidden and getCoffee() is made public, so that you will be able to send a request to the machine.</p>
<p>Since you have hidden the process, you don&#8217;t have any need to show how the coffee &amp; milk are mixed and how it&#8217;s been brewed. If you need a stylish design, even you can show that.</p>
<p style="text-align: center"><img src="http://mymindleaks.com/wp-content/uploads/2008/06/060908-0915-objectorien32.png" alt="060908 0915 objectorien32 Object Oriented Programming – Encapsulation is not just hiding data!"  title="Object Oriented Programming – Encapsulation is not just hiding data!" /></p>
<p>The Coffee Vending Machine encapsulates the internal process and the ingredients (data) used in the process.</p>
<p>Object Oriented Languages provides encapsulation via modifiers such as &#8220;private&#8221;, &#8220;protected&#8221;. Sometimes, volatile and transient also acts as encapsulating modifiers, but they are language specifics.</p>
<p>Encapsulation doesn&#8217;t stop just with OOP languages. The concept extends itself to the latest technology such as Webservices, Service Oriented Architecture. If you closely watch, any real world object has encapsulation in it, which the Object Oriented Programming tries to model.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mymindleaks.com/blog/archives/object-oriented-programming-%e2%80%93-encapsulation-is-not-just-hiding-data.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Object Oriented Programming &#8211; Abstraction</title>
		<link>http://www.mymindleaks.com/blog/archives/object-oriented-programming-abstraction.html</link>
		<comments>http://www.mymindleaks.com/blog/archives/object-oriented-programming-abstraction.html#comments</comments>
		<pubDate>Tue, 27 May 2008 01:15:03 +0000</pubDate>
		<dc:creator>Maheshwaran Subramaniya</dc:creator>
				<category><![CDATA[Articles on Computer Science]]></category>
		<category><![CDATA[Abstraction]]></category>
		<category><![CDATA[object oriented programming]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://mymindleaks.com/?p=651</guid>
		<description><![CDATA[Abstraction is a concept which facilitates to extract out the essential information of an object. In OOP ( Object Oriented Programming ) , Abstraction facilitates the easy conceptualization of real world objects into the software program. Abstraction lies everywhere! What ever you see, do and live are all full of abstraction. In mathematics, multiplication is [...]]]></description>
			<content:encoded><![CDATA[<p style="margin-left: 1pt">Abstraction is a concept which facilitates to extract out the essential information of an object.</p>
<p style="margin-left: 1pt">In OOP ( Object Oriented Programming ) , Abstraction facilitates the easy conceptualization of real world objects into the software program.</p>
<p style="margin-left: 1pt">Abstraction lies everywhere! What ever you see, do and live are all full of abstraction.</p>
<p style="margin-left: 1pt">In mathematics, <strong>multiplication </strong>is a kind of abstraction. The symbol &#8220;<span style="font-size:16pt"><strong>x</strong></span>&#8221; is an abstract symbol that can do multiplication of any two elements.<span style="font-size:12pt"><br />
</span></p>
<blockquote><p>2 <strong>x</strong> 3 = 6</p></blockquote>
<blockquote><p>3.5 <span style="font-size:16pt"><strong>x</strong></span> 3.7 = 12.95</p></blockquote>
<blockquote><p>(a + b) <span style="font-size:16pt"><strong>x</strong></span> ( a &#8211; b) = a^2 &#8211; b^2</p></blockquote>
<p style="margin-left: 1pt"><span id="more-651"></span></p>
<p style="margin-left: 1pt">In Art, Abstract Art is a kind of art, which depicts the distilled form of the world.</p>
<p style="margin-left: 1pt"><img src="http://mymindleaks.com/wp-content/uploads/2008/05/051808-0406-abstraction1.png" alt="051808 0406 abstraction1 Object Oriented Programming   Abstraction"  title="Object Oriented Programming   Abstraction" /><span style="font-size: 12pt; font-family: Times New Roman;"><br />
</span>
</p>
<p style="margin-left: 1pt">
<p style="margin-left: 1pt"><em>Courtesy: <a href="http://www.flickr.com/photos/regiaart/">RegiaArt</a></em></p>
<p><strong>So, what exactly an Abstraction is?</strong></p>
<p>Abstraction facilitates the easy conceptualization of real world objects, by eliminating the unnecessary details of the object. Unnecessary details? Yes, all the similar objects when you generalize, you will drop the uncommon details about the objects.</p>
<p>E.g., when you model a generic prototype for CRT Television &amp; a Plasma Television, you look for details like Type of screen, Height, Width, thickness etc.; these are necessary details for a Television. But a Television object doesn&#8217;t need to have details of what kind of Electron it will bean to power the CRT, what kind of liquid plasmas it will use to power the Plasma TVs. These kinds of details are unnecessary details.</p>
<p>Let&#8217;s take mobile phone as the real world example. Look at the below mobile phones.</p>
<p style="margin-left: 1pt">
<p style="text-align: center; margin-left: 1pt"><img src="http://mymindleaks.com/wp-content/uploads/2008/05/051808-0406-abstraction2.png" alt="051808 0406 abstraction2 Object Oriented Programming   Abstraction"  title="Object Oriented Programming   Abstraction" /><span style="font-size: 12pt; font-family: Times New Roman;"><br />
</span>
</p>
<p style="margin-left: 1pt">What do you feel about them?</p>
<ul style="margin-left: 37pt">
<li>Firstly, everything is Nokia Mobiles</li>
<li>You could see Slide, Flip and Bar models</li>
<li>You could see Music, Business &amp; 3G Mobiles</li>
<li>You could see QWERTY , Basic and No keypads</li>
<li>You could extra music player button on music edition.</li>
<li>The Color, Size, Weight, Look etc&#8230;</li>
<li>And even more…</li>
</ul>
<p style="margin-left: 1pt">So, for better understanding I organize the mobile phones in the below format.</p>
<p style="text-align: center; margin-left: 1pt"><img src="http://mymindleaks.com/wp-content/uploads/2008/05/051808-0406-abstraction3.png" alt="051808 0406 abstraction3 Object Oriented Programming   Abstraction"  title="Object Oriented Programming   Abstraction" /><span style="font-size: 12pt; font-family: Times New Roman;"><br />
</span>
</p>
<p style="margin-left: 1pt">Basically, all the mobiles belong to Nokia.</p>
<p style="margin-left: 1pt">Still need a better classification, I drill down to its features and conceptualize the mobiles in more general way. So, you could categorize the mobiles as</p>
<ul style="margin-left: 37pt">
<li>Music</li>
<li>Business</li>
<li>Gaming</li>
<li>Normal</li>
<li>3G</li>
</ul>
<p style="margin-left: 1pt">As a layman user, you will feel its weight, color, style. As a music lover, you will check for the memory, type of media files it supports, and type of communication between devices (Bluetooth, Wi-Fi etc). As a business person, you will check for the memory, type of business application etc.</p>
<p style="text-align: center; margin-left: 1pt"><img src="http://mymindleaks.com/wp-content/uploads/2008/05/051808-0406-abstraction4.png" alt="051808 0406 abstraction4 Object Oriented Programming   Abstraction"  title="Object Oriented Programming   Abstraction" /><span style="font-size: 12pt; font-family: Times New Roman;"><br />
</span>
</p>
<p style="margin-left: 1pt">Now, you have got the details of the each and every mobile. It&#8217;s time to extract the most essential details of these mobile categories. Here I use an Abstraction filter, which abstracts out the essential details. So, essential details, here I mean is the most common properties of the mobiles.</p>
<p style="margin-left: 1pt">So, now the conceptualization of mobile has still got finer. Now you can still go deep and get a finer concept to model a generic / abstract mobile, which can be turned into a beautiful mobile of your kind.</p>
<p style="margin-left: 1pt">
<p style="text-align: center; margin-left: 1pt"><img src="http://mymindleaks.com/wp-content/uploads/2008/05/051808-0406-abstraction5.png" alt="051808 0406 abstraction5 Object Oriented Programming   Abstraction"  title="Object Oriented Programming   Abstraction" /><span style="font-size: 12pt; font-family: Times New Roman;"><br />
</span>
</p>
<p style="margin-left: 1pt">Now, you have extracted out the necessary details for each category of mobile. You still fine grain it to get a mobile phone&#8217;s basic property with the Abstraction filter.</p>
<p style="text-align: center; margin-left: 1pt"><img src="http://mymindleaks.com/wp-content/uploads/2008/05/051808-0406-abstraction6.png" alt="051808 0406 abstraction6 Object Oriented Programming   Abstraction"  title="Object Oriented Programming   Abstraction" /><span style="font-size: 12pt; font-family: Times New Roman;"><br />
</span>
</p>
<p style="margin-left: 1pt">Now, here comes your basic design of the Nokia mobile phone. You have learnt how you will abstract properties from the real world objects. Now the question is how you do it in the programming language. In the Object oriented principles, abstraction is achieved via Inheritance (a widely used design pattern)</p>
<p style="margin-left: 1pt">The class diagram for the Nokia mobile using Inheritance look like below</p>
<p style="text-align: center; background: white; margin-left: 1pt"><img src="http://mymindleaks.com/wp-content/uploads/2008/05/051808-0406-abstraction7.png" alt="051808 0406 abstraction7 Object Oriented Programming   Abstraction"  title="Object Oriented Programming   Abstraction" /><span style="font-size: 12pt; font-family: Times New Roman;"><br />
</span>
</p>
<p style="margin-left: 1pt">You would have missed to understand the abstraction in the computer science. Here are few places where you could see how the abstraction works</p>
<ul style="margin-left: 37pt">
<li>Network Layers – OSI Model</li>
<li>Database Architecture – Data Abstraction ( Physical, Logical , View )</li>
<li>Polymorphism – Abstraction of Actions / Methods</li>
<li>Templates in C++ or Java – Abstraction of Common Objects</li>
<li>Data Structures – Abstract way to store &amp; retrieve the data</li>
<li>Many more…</li>
</ul>
<p>One important thing you need to remember is &#8216;Abstract objects&#8217; never exists in real world. It is just the concept that we build to understand the working of real world objects.</p>
<p>E.g., There is nothing is called a Television, you have CRT Television (this is known commonly as TV), Plasma TV or LCD TV.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mymindleaks.com/blog/archives/object-oriented-programming-abstraction.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
