<p dir="ltr">On Sun, Nov 29, 2015 at 6:17 AM, Michael Van Canneyt <<a href="mailto:michael@freepascal.org">michael@freepascal.org</a>> wrote:<br>
>><br>
> First of all, inheritance is inherent in object oriented programming, since<br>
> every object descends from a base object.<br>
> So saying that 'inheritance must die' is a stupid sentence or title for a<br>
> blog.</p>
<p dir="ltr">Now I see what's happened.<br>
My laziness made me just point to two links, because I did not want to write a complete example. I should have said before:<br>
1- Inheritance is evil, be careful, use it wisely -- fast food is evil too, but I eat (sometimes) anyway.<br>
2- I prefer composition instead inheritance because it's more simpler to use and understand.<br>
And the most important (for me):<br>
3- Composition is not about only 'has a' construction, but more about Decorator design pattern.</p>
<p dir="ltr">IMHO Decorators are more flexible to add features than use sublcasses.</p>
<p dir="ltr">> - Composition results in slower code (1), since the program must always<br>
> dereference and fetch an extra object.<br>
><br>
> - Composition results in more memory being used. Inheritance puts everything<br>
> in 1 block: parent+child.<br>
> Composition uses 2 blocks, plus a pointer to connect the two. Every memory<br>
> block introces an extra area.<br>
> If you have a really bad designed hierarchy, then the 'child' object needs<br>
> an extra pointer to the 'parent'.<br>
> Again extra memory.<br>
><br>
> - Composition results in slower code (2) because the extra memory blocks<br>
> must be managed.</p>
<p dir="ltr">Performance and memory, of course.<br>
Well, my priorities are design, simplicity and manutenability. I think we're both right, just depends of contexts and priorities.</p>
<p dir="ltr">> You can argue that this is irrelevant these days: well, it is relevant,<br>
> because the effect of this is exponential, not linear.</p>
<p dir="ltr">Yeah, I think like that in most cases, but you're right when says this is exponential problem. Not all problems can be solved with pure object orientation, of course, and that is the reason we have hammer and saw.</p>
<p dir="ltr">> Not a technical argument, but nevertheless: If you think about it,<br>
> composition is just some syntactic sugar for procedural programming, just as<br>
> they do in C.</p>
<p dir="ltr">I don't understand why do you think this.</p>
<p dir="ltr">> I thought it was obvious that my joke was aimed at the authors of the web<br>
> pages you posted, not at you.<br>
> Most likely, they were frustrated by having to use wrongly designed classes.</p>
<p dir="ltr">As I said above, I should had written my examples or have explained more my thoughts, but I didn't. My fault. Nevertheless you wrote for me, so I think the joke wasn't just for the links but for the general context, ie, what I said plus links.</p>
<p dir="ltr">> If I have offended you, I apologize for that, this surely was not my<br>
> intention.</p>
<p dir="ltr">I appreciate that. No problem. Let's put a rock in this debate and move on. Thanks.</p>
<p dir="ltr">Marcos Douglas</p>