On Fri, Sep 16, 2016 at 1:54 AM 'Greg Plowman' via julia-users < julia-users@googlegroups.com> wrote:
> Bart, > Which one is the FooData solution? > Is this Example 1,2 or 3? Or another solution. > > It's the one posted by Michael later. In the terminology of https://www.thoughtworks.com/insights/blog/composition-vs-inheritance-how-choose FooData and FoobarData would be implementation types, that could also have methods operate on them as part of the "implementation interface", while the AbstractFoo hierarchy is part of the problem domain and cleanly separated here, but using the implementation types by composition: abstract AbstractFoo type FooData bar baz #... several other fields end type FoobarData barbaz bazbaz #... several other fields type Foo <: AbstractFoo foodata::FooData Foo(bar, baz) = new(FooData(bar, baz)) end type Foobar <: AbstractFoo foodata::FooData foobardata::FoobarData Foobar(bar, baz, barbaz, bazbaz) = new(FooData(bar, baz), FooBarData(barbaz, bazbaz)) end