oop - Inheritance in .NET is useless? -
i'm quite new .net programming. know .net programming 100% object oriented. intriguing paragraph read in book asp.net 4 states
inheritance less useful might expect. in ordinary application, classes use containment , other relationships instead of inheritance, because inheritance can complicate life needlessly without delivering many benefits. dan appleman, renowned .net programmer, once described inheritance “the coolest feature you’ll never use.”
i'm little bit confused here , need .net programmers tell me should take , should leave.
edit
please people understand question, first author didn't literally "inheritance in .net useless", way zip hole question in words fit title. second, book apress , title is: "beginning asp.net 4 in c# 2010" page 72.
ouch. inheritance not useful, it's core concept, every class inherits system.object (not sure if there hacks/clr stuff doesn't).
also in technologies asp.net mvc use inheritance (by creating base controller).
everyone uses inheritance time, of time without realizing it. there not inheritance in smaller/medium sized apps, instead interfaces used, example dependency injection. however, pretty every non-trivial application tends have base class floating around somewhere other classes inherit.
i'm guessing that's author means, decision between defining base class or interfaces. microsoft recommends base classes, in real life interfaces seem more common. since c# not support multiple inheritance (a class has more 1 base class) interfaces offer more flexibility @ cost of not being able centralize common code or enforce constructors.
Comments
Post a Comment