Skip to main content
11 events
when toggle format what by license comment
Aug 7, 2013 at 17:24 comment added Job One thing that is really cool about interfaces is that methods can accept them as parameter types. I do not have a great example, but it is very powerful. You can accept an IEnumerable interface type for a parameter and not have to care about the particular implementation. You cannot achieve the same with a class hierarchy - you will end up dragging a much bigger view into an object (if you will) than you actually need.
Aug 7, 2013 at 16:58 answer added Kelso Sharp timeline score: -1
Oct 10, 2012 at 11:56 review First posts
Oct 10, 2012 at 15:42
Sep 30, 2012 at 12:01 history tweeted twitter.com/#!/StackProgrammer/status/252377614113718272
Sep 30, 2012 at 11:20 comment added tdammers Note that both approaches are in fact wrong here; you don't want a class MiniVan than inherits from Car; instead, you want a class Vehicle, with properties of types Chassis, Wheel, Engine, etc., and make those polymorphic. This is known as Composition, and you should favor code reuse through composition over code reuse through inheritance whenever possible.
Sep 30, 2012 at 7:54 comment added svick Not directly related to your question, but having ICloneable like this is usually not a good idea. You would end up casting the result anyways, so there is no reason to use an interface (or abstract class) here.
Sep 30, 2012 at 3:47 vote accept RealityDysfunction
Sep 30, 2012 at 3:45 answer added Sergey Kalinichenko timeline score: 3
Sep 30, 2012 at 3:40 answer added Turbot timeline score: 8
Sep 30, 2012 at 3:33 answer added Yusubov timeline score: 3
Sep 30, 2012 at 2:40 history asked RealityDysfunction CC BY-SA 3.0