<?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: Why do I need inheritance in OOP? Real-world examples.</title>
	<atom:link href="http://artemgolubev.com/why-do-i-need-inheritance-in-oop-real-world-examples/feed/" rel="self" type="application/rss+xml" />
	<link>http://artemgolubev.com/why-do-i-need-inheritance-in-oop-real-world-examples/</link>
	<description>Thoughts on software</description>
	<lastBuildDate>Thu, 01 Dec 2011 17:41:46 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: dude</title>
		<link>http://artemgolubev.com/why-do-i-need-inheritance-in-oop-real-world-examples/comment-page-1/#comment-203</link>
		<dc:creator>dude</dc:creator>
		<pubDate>Thu, 01 Dec 2011 17:41:46 +0000</pubDate>
		<guid isPermaLink="false">http://artemgolubev.com/why-do-i-need-inheritance-in-oop-real-world-examples/#comment-203</guid>
		<description>what is missing in your example, and what is on the main reasons to have polymorphism in the first place is this class:

public class PetTrainer {
 public void makeMyPetTalk(Pet p) {
  p.say();
 }
}

As you can see, PetTrainer can make any Pet talk - cats, dogs or even tigers that might come in the future.</description>
		<content:encoded><![CDATA[<p>what is missing in your example, and what is on the main reasons to have polymorphism in the first place is this class:</p>
<p>public class PetTrainer {<br />
 public void makeMyPetTalk(Pet p) {<br />
  p.say();<br />
 }<br />
}</p>
<p>As you can see, PetTrainer can make any Pet talk &#8211; cats, dogs or even tigers that might come in the future.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Artem</title>
		<link>http://artemgolubev.com/why-do-i-need-inheritance-in-oop-real-world-examples/comment-page-1/#comment-202</link>
		<dc:creator>Artem</dc:creator>
		<pubDate>Mon, 28 Nov 2011 08:14:19 +0000</pubDate>
		<guid isPermaLink="false">http://artemgolubev.com/why-do-i-need-inheritance-in-oop-real-world-examples/#comment-202</guid>
		<description>Awaisdar:
The reason why the same code won&#039;t work without correction in C# is the following:
in Java all methods are virtual by default, compare to C# where in order to make them virtual you have to specify &quot;virtual&quot; keyword. The following program is C# version of the example code:

using System;

namespace Test
{
    public class Pet {
        public virtual void say() { }
    }

    public class  Dog : Pet {
        public override void say() { Console.WriteLine(&quot;I am a dog.&quot;); }
    }

    public class  Cat : Pet {
        public override void say() { Console.WriteLine(&quot;I am a cat.&quot;); }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Pet pet1 = new Dog();
            Pet pet2 = new Cat();
            pet1.say();
            pet2.say();
            Console.ReadKey();
        }
    }
}</description>
		<content:encoded><![CDATA[<p>Awaisdar:<br />
The reason why the same code won&#8217;t work without correction in C# is the following:<br />
in Java all methods are virtual by default, compare to C# where in order to make them virtual you have to specify &#8220;virtual&#8221; keyword. The following program is C# version of the example code:</p>
<p>using System;</p>
<p>namespace Test<br />
{<br />
    public class Pet {<br />
        public virtual void say() { }<br />
    }</p>
<p>    public class  Dog : Pet {<br />
        public override void say() { Console.WriteLine(&#8221;I am a dog.&#8221;); }<br />
    }</p>
<p>    public class  Cat : Pet {<br />
        public override void say() { Console.WriteLine(&#8221;I am a cat.&#8221;); }<br />
    }</p>
<p>    class Program<br />
    {<br />
        static void Main(string[] args)<br />
        {<br />
            Pet pet1 = new Dog();<br />
            Pet pet2 = new Cat();<br />
            pet1.say();<br />
            pet2.say();<br />
            Console.ReadKey();<br />
        }<br />
    }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: awaisdar</title>
		<link>http://artemgolubev.com/why-do-i-need-inheritance-in-oop-real-world-examples/comment-page-1/#comment-201</link>
		<dc:creator>awaisdar</dc:creator>
		<pubDate>Fri, 25 Nov 2011 04:03:02 +0000</pubDate>
		<guid isPermaLink="false">http://artemgolubev.com/why-do-i-need-inheritance-in-oop-real-world-examples/#comment-201</guid>
		<description>in c# after
  Pet pet1 = new Dog();
            cat pet22 = new cat();
 when i called
pet1.say();// it shows the say method of Pet class not of dog class.
and pent22.say();//shows the Cat class&#039;s say method.

???????????????????</description>
		<content:encoded><![CDATA[<p>in c# after<br />
  Pet pet1 = new Dog();<br />
            cat pet22 = new cat();<br />
 when i called<br />
pet1.say();// it shows the say method of Pet class not of dog class.<br />
and pent22.say();//shows the Cat class&#8217;s say method.</p>
<p>???????????????????</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vlad Z (AX guy from Kharkov)</title>
		<link>http://artemgolubev.com/why-do-i-need-inheritance-in-oop-real-world-examples/comment-page-1/#comment-194</link>
		<dc:creator>Vlad Z (AX guy from Kharkov)</dc:creator>
		<pubDate>Wed, 31 Aug 2011 16:45:34 +0000</pubDate>
		<guid isPermaLink="false">http://artemgolubev.com/why-do-i-need-inheritance-in-oop-real-world-examples/#comment-194</guid>
		<description>I was skimming through the comments people say and, in fact, this is a quite good and simple example of why to use so-called Liskov principle. You can always generally call Pet-&gt;say() via Pet base-class pointer not caring what subclass it actually represents (Dog, Cat or Bird). This is good and right practice in OOP.

http://en.wikipedia.org/wiki/Liskov_substitution_principle</description>
		<content:encoded><![CDATA[<p>I was skimming through the comments people say and, in fact, this is a quite good and simple example of why to use so-called Liskov principle. You can always generally call Pet-&gt;say() via Pet base-class pointer not caring what subclass it actually represents (Dog, Cat or Bird). This is good and right practice in OOP.</p>
<p><a href="http://en.wikipedia.org/wiki/Liskov_substitution_principle" rel="nofollow">http://en.wikipedia.org/wiki/Liskov_substitution_principle</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shaan rizvi</title>
		<link>http://artemgolubev.com/why-do-i-need-inheritance-in-oop-real-world-examples/comment-page-1/#comment-191</link>
		<dc:creator>shaan rizvi</dc:creator>
		<pubDate>Thu, 21 Jul 2011 03:28:33 +0000</pubDate>
		<guid isPermaLink="false">http://artemgolubev.com/why-do-i-need-inheritance-in-oop-real-world-examples/#comment-191</guid>
		<description>you have need explanation of this topic with the help of daily life example..........</description>
		<content:encoded><![CDATA[<p>you have need explanation of this topic with the help of daily life example&#8230;&#8230;&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manzoor</title>
		<link>http://artemgolubev.com/why-do-i-need-inheritance-in-oop-real-world-examples/comment-page-1/#comment-178</link>
		<dc:creator>Manzoor</dc:creator>
		<pubDate>Thu, 17 Feb 2011 06:12:46 +0000</pubDate>
		<guid isPermaLink="false">http://artemgolubev.com/why-do-i-need-inheritance-in-oop-real-world-examples/#comment-178</guid>
		<description>Its simple and need more explanation.</description>
		<content:encoded><![CDATA[<p>Its simple and need more explanation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manzoor</title>
		<link>http://artemgolubev.com/why-do-i-need-inheritance-in-oop-real-world-examples/comment-page-1/#comment-177</link>
		<dc:creator>Manzoor</dc:creator>
		<pubDate>Thu, 17 Feb 2011 06:11:44 +0000</pubDate>
		<guid isPermaLink="false">http://artemgolubev.com/why-do-i-need-inheritance-in-oop-real-world-examples/#comment-177</guid>
		<description>You are actually explaining about Dynamic Method Dispatch. Its is better if you go for  any Real time Implementations of Inheritance.</description>
		<content:encoded><![CDATA[<p>You are actually explaining about Dynamic Method Dispatch. Its is better if you go for  any Real time Implementations of Inheritance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Girish</title>
		<link>http://artemgolubev.com/why-do-i-need-inheritance-in-oop-real-world-examples/comment-page-1/#comment-143</link>
		<dc:creator>Girish</dc:creator>
		<pubDate>Sun, 21 Feb 2010 07:17:05 +0000</pubDate>
		<guid isPermaLink="false">http://artemgolubev.com/why-do-i-need-inheritance-in-oop-real-world-examples/#comment-143</guid>
		<description>The Article is quiet good and useful, but need to be explained in depth by giving more real world exmples</description>
		<content:encoded><![CDATA[<p>The Article is quiet good and useful, but need to be explained in depth by giving more real world exmples</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://artemgolubev.com/why-do-i-need-inheritance-in-oop-real-world-examples/comment-page-1/#comment-130</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Sun, 25 Oct 2009 03:33:20 +0000</pubDate>
		<guid isPermaLink="false">http://artemgolubev.com/why-do-i-need-inheritance-in-oop-real-world-examples/#comment-130</guid>
		<description>You are actually giving examples of polymorphism, which is achived via inheritance (http://en.wikipedia.org/wiki/Type_polymorphism)</description>
		<content:encoded><![CDATA[<p>You are actually giving examples of polymorphism, which is achived via inheritance (<a href="http://en.wikipedia.org/wiki/Type_polymorphism)" rel="nofollow">http://en.wikipedia.org/wiki/Type_polymorphism)</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>

