Pros and cons of inheritance:
+ Self-updating
- Spaghetti
- Copypasta
Discuss
Name:
Anonymous2007-03-02 14:50 ID:GfkrBBY3
>>1
-> Spaghetti has nothing to do with a specific piece of technology.
-> Inheritance is about NOT copying-pasta-ing, it's about reusing.
Name:
Anonymous2007-03-02 14:56 ID:VBQ+V/j7
>>2
When you want to copypasta, which you may not need to, you can either copypasta and keep the flow of reading, or inherit, producing more spaghetti jump there jump here.
Inheritance it's like a hard link. In other words, self-updating copypasta.
Name:
Anonymous2007-03-02 15:12 ID:GfkrBBY3
>>3
When you copypasta in 50 different places, you need 50 different modifications each time you change just one line.
BTW, you forgot the "polymorphism" part, but that's OK if you don't know what it is...
Name:
Anonymous2007-03-02 19:05 ID:VBQ+V/j7
>>4 When you copypasta in 50 different places, you need 50 different modifications each time you change just one line. >>1 already counted it:
+ Self-updating
And polymorphism? How'd that be related to inheritance? Oooh, you use static languages. Then it matters. I use a language where it does not matter WTF are you doing things to as long as they work. So with dynamic languages, the static languages feature called polymorphism is granted from the start, and classes don't even need to be related, nor it's restricted to functions which are bound to objects or dictionaries of some kind. For example, map(function, list) → list is a form of polymorphism: as long as f is a function (stuff) → stuff, it'll work. Oh and stuff can be anything as well (and needless to say, the list can be heterogeneous).
Name:
Anonymous2007-03-02 19:06 ID:VBQ+V/j7
BTW, for the record I'll say I was trolling when I wrote >>1. Of course I'll take inheritance (or mixins) over copypasta.
Name:
Anonymous2007-03-03 9:45 ID:CBev4azF
inheritance is godly.
Name:
Anonymous2007-03-05 2:35 ID:9XCKMTTn
Late binding is a great way to make your programs harder to read. This goes for function pointers in C as much as for virtual methods in C++ and non-final methods in C# and Java. However, in the latter 3 it's far more common to have loads of virtual methods whereas in C you have maybe a couple of function pointers and they generally go like "one invocation site, many potential call destinations" making the confusion at least manageable.
Of course the point could be made that C++'s virtual methods should be used with discipline, and I totally agree with that.
Name:
Anonymous2007-03-05 8:59 ID:6oV5yJQd
- All methods should be virtual
- No method final
- No class abstract
- No properties private
- All types dynamic
- All collections heterogeneous
- No polymorphism or casting rules - everything works as long as it works
- All code is thus generic
- Multiple inheritance
- Mixins and realtime class, object, object's class and object's inheritance manipulation at will
- Lazy evaluation whenever possible
- Abuse of first-class functions
- Abuse of anonymous closures
- Macros a welcome feature
That's the vet's way of programming. If you don't like dynamic languages, then I suggest you stick with today's special: Java.