<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: How Inheritance is useful in reusing code for programmers?</title>
	<atom:link href="http://www.codebrothers.org/how-inheritance-is-useful-in-reusing-code-for-programmers/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codebrothers.org/how-inheritance-is-useful-in-reusing-code-for-programmers/</link>
	<description></description>
	<lastBuildDate>Sun, 01 Aug 2010 01:09:59 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: parth m</title>
		<link>http://www.codebrothers.org/how-inheritance-is-useful-in-reusing-code-for-programmers/comment-page-1/#comment-1335</link>
		<dc:creator>parth m</dc:creator>
		<pubDate>Tue, 09 Feb 2010 13:09:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.codebrothers.org/how-inheritance-is-useful-in-reusing-code-for-programmers/#comment-1335</guid>
		<description>Well, with inheritance, several child classes of a given base class will be able to use inheritable methods and fields of the base class as if it were their own, therefore achieving code re usability. They need not be re-programmed in the child classes unless the child class needs different / extra / more constrained functionality from them (this is however applicable to only methods). 

Take a scenario where you, as a programmer have been maintaining a library of classes partaining to geometric shapes for your paint program. Suppose that you have a &quot;Rectangle&quot; class which has four points along with their x,y coordinates, their color values and the code that is used to paint them onto screen. Now suppose that someone else wants to also build a &quot;Square&quot; class, that is one of the most common uses of the Rectangle class. He will build a &quot;Square&quot; class that will inherit from the Rectangle class its four coordinate points and its drawing code. The only difference here is that the Square will impose constraints on the value of the points so that they are equidistant from their adjescent respective points, thus successfully defining a Square. The four coordinate fields as well as the painting code need not be re-programmed in the new Square class. They can now the invoked from a Square instance just as from a Rectangle, provided that were inheritable (public or protected. This will depend on the specific language you use.) 

However, inheritance, solely for code-reuse is strictly discouraged. This is the reason I have deliberately chose a Rectangle and Square example because Square IS-A rectangle, but with some extra properties. Avoid inheritance if such IS-A relationships do not arise.</description>
		<content:encoded><![CDATA[<p>Well, with inheritance, several child classes of a given base class will be able to use inheritable methods and fields of the base class as if it were their own, therefore achieving code re usability. They need not be re-programmed in the child classes unless the child class needs different / extra / more constrained functionality from them (this is however applicable to only methods). </p>
<p>Take a scenario where you, as a programmer have been maintaining a library of classes partaining to geometric shapes for your paint program. Suppose that you have a &quot;Rectangle&quot; class which has four points along with their x,y coordinates, their color values and the code that is used to paint them onto screen. Now suppose that someone else wants to also build a &quot;Square&quot; class, that is one of the most common uses of the Rectangle class. He will build a &quot;Square&quot; class that will inherit from the Rectangle class its four coordinate points and its drawing code. The only difference here is that the Square will impose constraints on the value of the points so that they are equidistant from their adjescent respective points, thus successfully defining a Square. The four coordinate fields as well as the painting code need not be re-programmed in the new Square class. They can now the invoked from a Square instance just as from a Rectangle, provided that were inheritable (public or protected. This will depend on the specific language you use.) </p>
<p>However, inheritance, solely for code-reuse is strictly discouraged. This is the reason I have deliberately chose a Rectangle and Square example because Square IS-A rectangle, but with some extra properties. Avoid inheritance if such IS-A relationships do not arise.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
