Jump to page: 1 2
Thread overview
Blog post : OOP composition with mixins
Aug 24, 2015
Dicebot
Aug 24, 2015
Atila Neves
Aug 31, 2015
Abdulhaq
Sep 01, 2015
Robert M. Münch
Aug 24, 2015
Dejan Lekic
Aug 25, 2015
thedeemon
Aug 31, 2015
jmh530
Aug 31, 2015
Dicebot
Sep 01, 2015
Luís Marques
Sep 01, 2015
Dicebot
Sep 01, 2015
cym13
Sep 01, 2015
Dicebot
Sep 01, 2015
Meta
Sep 01, 2015
Dicebot
Sep 01, 2015
Meta
August 24, 2015
Rough summary of the talk I have given for recent Berlin D meetup event:
https://blog.dicebot.lv/posts/2015/08/OOP_composition_with_mixins
August 24, 2015
On Monday, 24 August 2015 at 11:10:16 UTC, Dicebot wrote:
> Rough summary of the talk I have given for recent Berlin D meetup event:
> https://blog.dicebot.lv/posts/2015/08/OOP_composition_with_mixins

Nice. I've only just started exploring code reuse with template mixins, and used it to great effect in my last project. Blogs like this are useful since there aren't many examples in other languages (Ruby modules come to mind).

Atila
August 24, 2015
Good article.

However, composition also has some drawbacks and they should be explained.

Speaking about Java and inheritance, and popular believe it is overused - Yes, maybe it is, but Java does not have language features D has, and it should not be blamed for that. Interesting article for those looking for "more serious" criticism of Java and inheritance: https://www.cs.auckland.ac.nz/~ewan/qualitas/studies/inheritance/TemperoYangNobleECOOP2013-pre.pdf

What I think D community would benefit from would be a series of "Idiomatic D" articles.
August 25, 2015
On Monday, 24 August 2015 at 16:21:04 UTC, Dejan Lekic wrote:

> What I think D community would benefit from would be a series of "Idiomatic D" articles.

This collection of short pieces comes to mind:
http://p0nce.github.io/d-idioms/
August 31, 2015
On Monday, 24 August 2015 at 13:28:23 UTC, Atila Neves wrote:
> On Monday, 24 August 2015 at 11:10:16 UTC, Dicebot wrote:
>> Rough summary of the talk I have given for recent Berlin D meetup event:
>> https://blog.dicebot.lv/posts/2015/08/OOP_composition_with_mixins
>
> Nice. I've only just started exploring code reuse with template mixins, and used it to great effect in my last project. Blogs like this are useful since there aren't many examples in other languages (Ruby modules come to mind).
>
> Atila

Inheritance certainly is 'the base class of all evil'. I have a theory that the reason inheritance is so overused in OOP languages lies in the way it is taught - the OOP aspects cover much of the syntax of the language and hence much teaching material revolves around inheritance. This makes the student believe that inheritance is therefore the 'right way' to proceed. Many years of pain have, however, taught me to avoid inheritance and to prefer composition - even/especially when using e.g. Java.
August 31, 2015
On Monday, 24 August 2015 at 11:10:16 UTC, Dicebot wrote:
> Rough summary of the talk I have given for recent Berlin D meetup event:
> https://blog.dicebot.lv/posts/2015/08/OOP_composition_with_mixins

It seems like mixin templates can be used like alias this, but mixin templates are more general. When would I want to use alias this instead of a mixin template?
August 31, 2015
On Monday, 31 August 2015 at 14:44:27 UTC, jmh530 wrote:
> On Monday, 24 August 2015 at 11:10:16 UTC, Dicebot wrote:
>> Rough summary of the talk I have given for recent Berlin D meetup event:
>> https://blog.dicebot.lv/posts/2015/08/OOP_composition_with_mixins
>
> It seems like mixin templates can be used like alias this, but mixin templates are more general. When would I want to use alias this instead of a mixin template?

`alias this` is more suitable for cases when reused functionality is self-contained and useful separately. It is closer in spirit to inheritance because you take existing entity and provide its API as part of new aggregate.

As a simple rule of a thumb, I'd go for `alias this` approach when mixed in functionality does not need to know anything about surrounding context (== has no template parameters). mixin template feels more convenient for small configurable building blocks that don't have well-defined semantics without any specific context.

Important difference between `alias this` and `mixin` is that `alias this` allows implicit casting to the aliased field type - which can be both merit and drawback depending on design intentions.
September 01, 2015
On 2015-08-31 14:20:23 +0000, Abdulhaq said:

> Inheritance certainly is 'the base class of all evil'. I have a theory that the reason inheritance is so overused in OOP languages lies in the way it is taught - the OOP aspects cover much of the syntax of the language and hence much teaching material revolves around inheritance. This makes the student believe that inheritance is therefore the 'right way' to proceed.

I think what's missing is, that inheritance should be used with a type-system view in mind. It makes sense to model "typed things" but not to model functionallity / re-using of functionallity. This is much bettern done with a concept like mixins.

And mixing both is a very powerful way to model complex system. You "just" need to know when to use one or the other.

>  Many years of pain have, however, taught me to avoid inheritance and to prefer composition - even/especially when using e.g. Java.

Because all those OOP languages are to dogmatic about it's use. C++ is free, but is missing (not sure if still) the template and mixin power of D.

-- 
Robert M. Münch
http://www.saphirion.com
smarter | better | faster

September 01, 2015
On Monday, 24 August 2015 at 11:10:16 UTC, Dicebot wrote:
> Rough summary of the talk I have given for recent Berlin D meetup event:
> https://blog.dicebot.lv/posts/2015/08/OOP_composition_with_mixins

I'm having trouble resolving that DNS name.
September 01, 2015
On Tuesday, 1 September 2015 at 10:18:08 UTC, Luís Marques wrote:
> On Monday, 24 August 2015 at 11:10:16 UTC, Dicebot wrote:
>> Rough summary of the talk I have given for recent Berlin D meetup event:
>> https://blog.dicebot.lv/posts/2015/08/OOP_composition_with_mixins
>
> I'm having trouble resolving that DNS name.

Technical server issues, should be back now.
« First   ‹ Prev
1 2