<?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"
	>

<channel>
	<title>My Mind Leaks... &#187; Programming</title>
	<atom:link href="http://mymindleaks.com/articles/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://mymindleaks.com</link>
	<description>Live with Feel of Technology and Blogging</description>
	<pubDate>Thu, 13 Nov 2008 02:31:54 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<item>
		<title>Object Oriented Programming – Encapsulation is not just hiding data!</title>
		<link>http://mymindleaks.com/programming/object-oriented-programming-%e2%80%93-encapsulation-is-not-just-hiding-data/</link>
		<comments>http://mymindleaks.com/programming/object-oriented-programming-%e2%80%93-encapsulation-is-not-just-hiding-data/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 09:15:43 +0000</pubDate>
		<dc:creator>SM</dc:creator>
		
		<category><![CDATA[Programming]]></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 Encapsulation [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Object Oriented Programming – Encapsulation is not just hiding data!", url: "http://mymindleaks.com/programming/object-oriented-programming-%e2%80%93-encapsulation-is-not-just-hiding-data/" });</script>]]></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="" /></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 ;-)) 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="" /></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="" /></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>
<p><a href="http://sharethis.com/item?&wp=2.5&amp;publisher=cb905db7-228f-4691-8f89-e07ff141e3db&amp;title=Object+Oriented+Programming+%E2%80%93+Encapsulation+is+not+just+hiding+data%21&amp;url=http%3A%2F%2Fmymindleaks.com%2Fprogramming%2Fobject-oriented-programming-%25e2%2580%2593-encapsulation-is-not-just-hiding-data%2F">ShareThis</a></p>
	Tagged in My Mind as: <a href="http://mymindleaks.com/tag/encapsulation/" title="Encapsulation" rel="tag nofollow">Encapsulation</a>, <a href="http://mymindleaks.com/tag/featured/" title="Featured" rel="tag nofollow">Featured</a>, <a href="http://mymindleaks.com/tag/object-oriented-programming/" title="object oriented programming" rel="tag nofollow">object oriented programming</a>, <a href="http://mymindleaks.com/tag/resources/" title="Resources" rel="tag nofollow">Resources</a><br />

	<h4>Related posts</h4>
	<ul class='st-related-posts'>
	<li><a href="http://mymindleaks.com/apple/why-you-wont-love-macbook-air/" title="Why you won&#8217;t love MacBook Air (February 18, 2008)">Why you won&#8217;t love MacBook Air</a> (4)</li>
	<li><a href="http://mymindleaks.com/technology/web-20-lazy-yet-powerful-part-2/" title="Web 2.0, Lazy yet Powerful - Part 2 (March 10, 2008)">Web 2.0, Lazy yet Powerful - Part 2</a> (4)</li>
	<li><a href="http://mymindleaks.com/technology/web-20-lazy-yet-powerful-part-1/" title="Web 2.0, Lazy yet Powerful - Part 1 (March 9, 2008)">Web 2.0, Lazy yet Powerful - Part 1</a> (9)</li>
	<li><a href="http://mymindleaks.com/windows-xp/use-shell-for-quick-windows-xp-vista-run-commands/" title="Use Shell: for quick Windows XP &amp; Vista Run Commands (April 17, 2008)">Use Shell: for quick Windows XP &amp; Vista Run Commands</a> (2)</li>
	<li><a href="http://mymindleaks.com/search-engine-optimization/test-your-web-design-in-63-browsers-and-4-operating-systems/" title="Test your web design in 63 browsers and 4 Operating Systems (March 19, 2008)">Test your web design in 63 browsers and 4 Operating Systems</a> (4)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://mymindleaks.com/programming/object-oriented-programming-%e2%80%93-encapsulation-is-not-just-hiding-data/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Object Oriented Programming - Abstraction</title>
		<link>http://mymindleaks.com/programming/object-oriented-programming-abstraction/</link>
		<comments>http://mymindleaks.com/programming/object-oriented-programming-abstraction/#comments</comments>
		<pubDate>Tue, 27 May 2008 01:15:03 +0000</pubDate>
		<dc:creator>SM</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Abstraction]]></category>

		<category><![CDATA[object oriented programming]]></category>

		<category><![CDATA[OOP]]></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 a kind of [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Object Oriented Programming - Abstraction", url: "http://mymindleaks.com/programming/object-oriented-programming-abstraction/" });</script>]]></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 <span style="font-size:16pt"><strong>x</strong></span> 3 = 6 <span style="font-size:12pt"><br />
</span></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 - b) = a^2 - 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="" /><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="" /><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="" /><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="" /><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="" /><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="" /><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="" /><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>
<p><a href="http://sharethis.com/item?&wp=2.5&amp;publisher=cb905db7-228f-4691-8f89-e07ff141e3db&amp;title=Object+Oriented+Programming+-+Abstraction&amp;url=http%3A%2F%2Fmymindleaks.com%2Fprogramming%2Fobject-oriented-programming-abstraction%2F">ShareThis</a></p>
	Tagged in My Mind as: <a href="http://mymindleaks.com/tag/abstraction/" title="Abstraction" rel="tag nofollow">Abstraction</a>, <a href="http://mymindleaks.com/tag/object-oriented-programming/" title="object oriented programming" rel="tag nofollow">object oriented programming</a>, <a href="http://mymindleaks.com/tag/oop/" title="OOP" rel="tag nofollow">OOP</a>, <a href="http://mymindleaks.com/tag/programming/" title="Programming" rel="tag nofollow">Programming</a><br />

	<h4>Related posts</h4>
	<ul class='st-related-posts'>
	<li><a href="http://mymindleaks.com/programming/object-oriented-programming-%e2%80%93-encapsulation-is-not-just-hiding-data/" title="Object Oriented Programming – Encapsulation is not just hiding data! (June 9, 2008)">Object Oriented Programming – Encapsulation is not just hiding data!</a> (4)</li>
	<li><a href="http://mymindleaks.com/windows-xp/how-to-auto-map-windows-network-drives/" title="How to auto map Windows network drives (August 22, 2008)">How to auto map Windows network drives</a> (1)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://mymindleaks.com/programming/object-oriented-programming-abstraction/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Big Code, Good Code!</title>
		<link>http://mymindleaks.com/programming/big-code-good-code/</link>
		<comments>http://mymindleaks.com/programming/big-code-good-code/#comments</comments>
		<pubDate>Fri, 09 May 2008 01:32:57 +0000</pubDate>
		<dc:creator>SM</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Coding]]></category>

		<category><![CDATA[Featured]]></category>

		<category><![CDATA[guide]]></category>

		<guid isPermaLink="false">http://mymindleaks.com/?p=622</guid>
		<description><![CDATA[Coding is an art! Anyone can draw, but only those who draw with the elegant have their paintings valued. Similarly any programmer can code, but a Good Program is an artistic job. I see lot of people do code, but only few actually write Good code. This means they have understood the elegance of the [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Big Code, Good Code!", url: "http://mymindleaks.com/programming/big-code-good-code/" });</script>]]></description>
			<content:encoded><![CDATA[<p><em>Coding is an art</em>! Anyone can draw, but only those who draw with the elegant have their paintings valued. Similarly any programmer can code, but a Good Program is an artistic job. I see lot of people do code, but only few actually write Good code. This means they have understood the elegance of the language and knows how to use it.</p>
<h3>Big Code - Good Code</h3>
<p>Big Code, a Good Code? Sounds awkward? A Good code I mean here is a code which runs quicker than other solutions for the same problem.</p>
<blockquote><p><strong>if T(Sol1) &lt; T(Sol2) Then, Solution 1 is a Good code</strong>., Where T is Time function , measures Time Taken</p></blockquote>
<p><em>( though there are various other constraints involved, for time being let not discuss them )</em></p>
<p>Hardcore programmers are always tries to write short programs. They couple few lines of code into one and show that they have done a great coding.  But, things are not always the way it looks. <strong><em>Short is sweet, but not always !</em></strong></p>
<p><span id="more-622"></span><br />
Look into this code, 3 solutions for one simple problem.</p>
<p><em><strong>Problem</strong>: Find the greatest of two numbers a, b</em></p>
<p style="text-align: center"><a href="http://mymindleaks.com/wp-content/uploads/2008/05/code-table1.png"><img src="http://mymindleaks.com/wp-content/uploads/2008/05/code-table-thumb.png" border="0" alt="code-table" width="640" height="158" /></a></p>
<h3>Million Dollar Question</h3>
<p>Which code runs faster? If you have chosen the A&#8217;s code as faster. You have correctly made a <strong>wrong decision</strong>.</p>
<p>The fastest program is the B&#8217;s program. So, 3 lines of code, still fastest code? Ok.</p>
<p>In the A&#8217;s code,  consider if a &lt; b, two operations should be performed.</p>
<ul>
<li>Compare &#8216;a&#8217; , &#8216;b&#8217;</li>
<li>Branch to Else if &#8216;a&#8217; &lt; &#8216;b&#8217;</li>
<li>Return the expression &#8216;b&#8217;</li>
</ul>
<p>But in B&#8217;s solution, we have already assigned a value to &#8216;x&#8217;. Only job is to compare and Assign. <strong>So the second operation is saved.</strong></p>
<p>In such a small code, you won&#8217;t find a big difference. But think of a macro system with MLOC ( Million Lines of Code ).</p>
<p>I will explain you by solving a bit complex problem, come on join me.</p>
<p><strong>Problem</strong>: <em>Given number &#8216;N&#8217; , split into &#8216;k&#8217; integers, such that N = k1 + k2 + k3 +&#8230;kn and k1 * k2 * k3 is maximum</em>.</p>
<p>You can try various solutions. One simple solution is</p>
<p style="text-align: center"><img src="http://mymindleaks.com/wp-content/uploads/2008/05/image-thumb.png" border="0" alt="image" width="640" height="69" /></p>
<p>Great code, you would be proud to write one line solution of such great problem. But wait, is your code is faster to run for N &gt; 10^10, K &gt; 10^5?</p>
<p>Consider the optimize solution</p>
<p style="text-align: center"><a href="http://mymindleaks.com/wp-content/uploads/2008/05/image1.png"><img src="http://mymindleaks.com/wp-content/uploads/2008/05/image-thumb1.png" border="0" alt="image" width="640" height="125" /></a></p>
<p>More optimised</p>
<p style="text-align: center"><a href="http://mymindleaks.com/wp-content/uploads/2008/05/image5.png"><img src="http://mymindleaks.com/wp-content/uploads/2008/05/image-thumb5.png" border="0" alt="image" width="640" height="200" /></a></p>
<p>The last code works much faster than any other. Try looping it for million times with various values of &#8216;N &amp; k &#8216;. and measure the time it takes to complete the million time execution.</p>
<h3>How to write a speedy code?</h3>
<p>So, this is yet another million dollar question. Take a look at the above three solutions. You will find a resemblance.</p>
<p><strong>Solution - 1 </strong>is a generalized form of other two. <strong>Solution - 3 </strong>is more detailed form of Solution - 1.</p>
<p>So, what is been detailed in the Solution 3. If you look at more closely, you will find that Solution-3 has checks for &#8216;Boundary Conditions&#8217;.</p>
<p>Boundary Conditions are very important scenarios in any Logical System. You prove that system works perfect for boundary conditions, you prove the system to work for any values between it. <strong>Similar to Mathematical Induction</strong>. So, this applies for programming too.</p>
<p>If you are able to identify the boundary conditions, and make the appropriate formula for those conditions, then you will skip unnecessary computations.</p>
<p>We will look what have save the computational cycles.</p>
<p>Lets assume, the Input are N=10, K = 2</p>
<p><strong>Using Solution-1:</strong></p>
<p>residue = 0, mid = 5</p>
<p>maxProduct = Math.pow(5+1,0) * Math.pow( 5 ,(2-0) ) = 25</p>
<p><strong>Operations performed:</strong></p>
<p><em>Note: costs are just for calculation, not exact one</em></p>
<p><a href="http://mymindleaks.com/wp-content/uploads/2008/05/image3.png"><img src="http://mymindleaks.com/wp-content/uploads/2008/05/image-thumb3.png" border="0" alt="image" width="270" height="322" /></a></p>
<ul>
<li>Math.pow</li>
<li>Addition - (5+1)</li>
<li>Math.pow</li>
<li>Subtraction - ( 2-0 )</li>
<li>Multiplication</li>
</ul>
<p>lets assume the cost for each operation is</p>
<p><strong>Using Solution-3:</strong></p>
<p>The code will branch out to the 1st if condition ( residue == 0 )</p>
<p>maxProduct = Math.pow( 5, 2) = 25</p>
<p><strong>Operations performed</strong></p>
<p><a href="http://mymindleaks.com/wp-content/uploads/2008/05/image4.png"><img src="http://mymindleaks.com/wp-content/uploads/2008/05/image-thumb4.png" border="0" alt="image" width="270" height="166" /></a></p>
<p>So, you have saved more than 55% of the computational cycles by covering up the boundary conditions.</p>
<p><strong>So, Why you need a Speedy code?</strong></p>
<p>Everyone in life loves speed. Speed bike, Speed cars ( that&#8217;s why you would love F1 ), A speedy 2 GB - Core 2 Duo Powered Machine.</p>
<p><strong>Because Speed makes you feel Good !! So does a Speedy Code will be a Good code.</strong></p>
<p>But, to achieve something you have to compromise with other factors, like I mentioned earlier.</p>
<p>If you need a 2 GB - Core 2 Duo Powered Machine, you should not consider the Money factor.</p>
<p>Similarly while you code, there are lot of other factors like</p>
<ul>
<li>Memory Management</li>
<li>Security</li>
<li>Transaction Isolations etc.,</li>
</ul>
<p>This is just a introduction, will start covering up other topics soon.</p>
<p><a href="http://sharethis.com/item?&wp=2.5&amp;publisher=cb905db7-228f-4691-8f89-e07ff141e3db&amp;title=Big+Code%2C+Good+Code%21&amp;url=http%3A%2F%2Fmymindleaks.com%2Fprogramming%2Fbig-code-good-code%2F">ShareThis</a></p>
	Tagged in My Mind as: <a href="http://mymindleaks.com/tag/coding/" title="Coding" rel="tag nofollow">Coding</a>, <a href="http://mymindleaks.com/tag/featured/" title="Featured" rel="tag nofollow">Featured</a>, <a href="http://mymindleaks.com/tag/guide/" title="guide" rel="tag nofollow">guide</a><br />

	<h4>Related posts</h4>
	<ul class='st-related-posts'>
	<li><a href="http://mymindleaks.com/apple/why-you-wont-love-macbook-air/" title="Why you won&#8217;t love MacBook Air (February 18, 2008)">Why you won&#8217;t love MacBook Air</a> (4)</li>
	<li><a href="http://mymindleaks.com/technology/web-20-lazy-yet-powerful-part-2/" title="Web 2.0, Lazy yet Powerful - Part 2 (March 10, 2008)">Web 2.0, Lazy yet Powerful - Part 2</a> (4)</li>
	<li><a href="http://mymindleaks.com/technology/web-20-lazy-yet-powerful-part-1/" title="Web 2.0, Lazy yet Powerful - Part 1 (March 9, 2008)">Web 2.0, Lazy yet Powerful - Part 1</a> (9)</li>
	<li><a href="http://mymindleaks.com/search-engine-optimization/test-your-web-design-in-63-browsers-and-4-operating-systems/" title="Test your web design in 63 browsers and 4 Operating Systems (March 19, 2008)">Test your web design in 63 browsers and 4 Operating Systems</a> (4)</li>
	<li><a href="http://mymindleaks.com/productivity/stop-all-annoying-messages-from-twitter-pownce-get-friendfeed/" title="Stop all annoying messages from Twitter &amp; Pownce, get FriendFeed (March 4, 2008)">Stop all annoying messages from Twitter &amp; Pownce, get FriendFeed</a> (2)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://mymindleaks.com/programming/big-code-good-code/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.609 seconds -->
