digitalmars.D.announce - Blog post : OOP composition with mixins
- Dicebot (3/3) Aug 24 2015 Rough summary of the talk I have given for recent Berlin D meetup
- Atila Neves (6/9) Aug 24 2015 Nice. I've only just started exploring code reuse with template
- Abdulhaq (9/18) Aug 31 2015 Inheritance certainly is 'the base class of all evil'. I have a
- =?iso-8859-1?Q?Robert_M._M=FCnch?= (14/22) Aug 31 2015 I think what's missing is, that inheritance should be used with a
- Dejan Lekic (11/11) Aug 24 2015 Good article.
- thedeemon (3/5) Aug 25 2015 This collection of short pieces comes to mind:
- jmh530 (4/7) Aug 31 2015 It seems like mixin templates can be used like alias this, but
- Dicebot (15/22) Aug 31 2015 `alias this` is more suitable for cases when reused functionality
- =?UTF-8?B?Ikx1w61z?= Marques" (2/5) Sep 01 2015 I'm having trouble resolving that DNS name.
- Dicebot (2/7) Sep 01 2015 Technical server issues, should be back now.
- Meta (2/5) Sep 01 2015 Are you planning on submitting this article to Reddit/Hacker News?
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
Aug 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_mixinsNice. 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
Aug 24 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: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.Rough summary of the talk I have given for recent Berlin D meetup event: https://blog.dicebot.lv/posts/2015/08/OOP_composition_with_mixinsNice. 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
Aug 31 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
Aug 31 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.
Aug 24 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/
Aug 25 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_mixinsIt 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?
Aug 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:`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.Rough summary of the talk I have given for recent Berlin D meetup event: https://blog.dicebot.lv/posts/2015/08/OOP_composition_with_mixinsIt 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?
Aug 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_mixinsI'm having trouble resolving that DNS name.
Sep 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:Technical server issues, should be back now.Rough summary of the talk I have given for recent Berlin D meetup event: https://blog.dicebot.lv/posts/2015/08/OOP_composition_with_mixinsI'm having trouble resolving that DNS name.
Sep 01 2015
On Tuesday, 1 September 2015 at 11:36:49 UTC, Dicebot wrote:On Tuesday, 1 September 2015 at 10:18:08 UTC, LuĂs Marques wrote:BTW, a bit HS but in your article about Rust (https://blog.dicebot.lv/posts/2015/01/thoughts_about_rust_from_d_programmer) there is a “</code>” lying in the first example.On Monday, 24 August 2015 at 11:10:16 UTC, Dicebot wrote:Technical server issues, should be back now.Rough summary of the talk I have given for recent Berlin D meetup event: https://blog.dicebot.lv/posts/2015/08/OOP_composition_with_mixinsI'm having trouble resolving that DNS name.
Sep 01 2015
On Tuesday, 1 September 2015 at 13:44:15 UTC, cym13 wrote:BTW, a bit HS but in your article about Rust (https://blog.dicebot.lv/posts/2015/01/thoughts_about_rust_from_d_programmer) there is a “</code>” lying in the first example.Thanks, fixed.
Sep 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_mixinsAre you planning on submitting this article to Reddit/Hacker News?
Sep 01 2015
On Tuesday, 1 September 2015 at 14:11:44 UTC, Meta wrote:On Monday, 24 August 2015 at 11:10:16 UTC, Dicebot wrote:There is something wrong about submitting own articles into aggregators :) Feel free to do so if you want to.Rough summary of the talk I have given for recent Berlin D meetup event: https://blog.dicebot.lv/posts/2015/08/OOP_composition_with_mixinsAre you planning on submitting this article to Reddit/Hacker News?
Sep 01 2015
On Tuesday, 1 September 2015 at 14:32:11 UTC, Dicebot wrote:On Tuesday, 1 September 2015 at 14:11:44 UTC, Meta wrote:Sounds good to me. https://www.reddit.com/r/programming/comments/3j8bi2/oop_composition_with_mixins_in_the_d_programming/On Monday, 24 August 2015 at 11:10:16 UTC, Dicebot wrote:There is something wrong about submitting own articles into aggregators :) Feel free to do so if you want to.Rough summary of the talk I have given for recent Berlin D meetup event: https://blog.dicebot.lv/posts/2015/08/OOP_composition_with_mixinsAre you planning on submitting this article to Reddit/Hacker News?
Sep 01 2015