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.

On Monday, September 12, 2016 at 11:45:40 AM UTC-7, Bart Janssens wrote:
>
> Looking at this example, it seems mighty tempting to have the ability to 
> subtype a concrete type. Are the exact problems with that documented 
> somewhere? I am aware of the following section in the docs:
>
> "One particularly distinctive feature of Julia’s type system is that 
> concrete types may not subtype each other: all concrete types are final and 
> may only have abstract types as their supertypes. While this might at first 
> seem unduly restrictive, it has many beneficial consequences with 
> surprisingly few drawbacks. It turns out that being able to inherit 
> behavior is much more important than being able to inherit structure, and 
> inheriting both causes significant difficulties in traditional 
> object-oriented languages."
>
> I'm just wondering what the "significant difficulties" are, not advocating 
> changing this behaviour.
>
> On Mon, Sep 12, 2016 at 5:28 PM Stefan Karpinski <ste...@karpinski.org 
> <javascript:>> wrote:
>
>> I would probably go with approach #2 myself and only refer to the .bar 
>> and .baz fields in all of the generic AbstractFoo methods.
>>
>> On Mon, Sep 12, 2016 at 10:10 AM, Michael Borregaard <mkborr...@gmail.com 
>> <javascript:>> wrote:
>>
>>> Hi,
>>>
>>> I am defining a set of types to hold scientific data, and trying to get 
>>> the best out of Julia's type system. The types in my example are 'nested' 
>>> in the sense that each type will hold progressively more information and 
>>> thus allow the user to do progressively more. Like this:
>>>
>>> type Foo
>>>   bar
>>>   baz
>>> end
>>>
>>> type Foobar
>>>   bar  # this
>>>   baz  # and this are identical with Foo
>>>   barbaz
>>>   bazbaz
>>> end
>>>
>>>
>>

Reply via email to