Thanks for the replies, very informative. I like the FooData solution best,
it separates "code reuse through composition" from "shared interface
through inheritance", which is what is recommended in the thoughtworks link
Chris posted.

On Mon, Sep 12, 2016 at 11:44 PM Stefan Karpinski <ste...@karpinski.org>
wrote:

> The biggest practical issue is that if you can subtype a concrete type
> then you can't store values inline in an array, even if the values are
> immutable – since a subtype can be bigger than the supertype. This leads to
> having things like "final" classes, etc. Fundamentally, this is really an
> issue of failing to separate the concrete type – which is complete and can
> be instantiated – from the abstract type, which is incomplete and can be
> subtyped.
>
> On Mon, Sep 12, 2016 at 3:17 PM, Chris Rackauckas <rackd...@gmail.com>
> wrote:
>
>> https://en.wikipedia.org/wiki/Composition_over_inheritance
>>
>>
>> http://programmers.stackexchange.com/questions/134097/why-should-i-prefer-composition-over-inheritance
>>
>>
>> https://www.thoughtworks.com/insights/blog/composition-vs-inheritance-how-choose
>>
>> That's just the start. Overtime, people realized inheritance can be quite
>> fragile, so many style guidelines simply forbid you from doing it.
>>
>>

Reply via email to