3 ms·
Is that an example of decorator pattern?
by jmartrican 5y ago
Is that an example of decorator pattern?
- filleduchaos 5y agoI'd say that that's an example of structural or duck typing (as opposed to nominal typing). In my experience it is nigh impossible to design-pattern your way out of a language simply being unable to express what you need it to express without incurring a severe performance penalty (anathema for game development) or resorting to code generation (which is itself prone to ending up as a Gordian knot).
- lmm 5y ago> I'd say that that's an example of structural or duck typing (as opposed to nominal typing). No it's not. I'm talking about having nominal typing but easy support for delegation (e.g. look at how Kotlin does it).
- lmm 5y agoKinda - an instance of an OO subclass is a decorator around an instance of its superclass, so if you're using a language which has a good way of expressing decoration then that's usually better than using inheritance. But as the other reply said, patterns are a language smell - the language needs to support that style and make it idiomatic. Otherwise, if you give people the choice between doing it right but verbosely and doing it wrong but more quickly, guess which one they'll choose. https://www.haskellforall.com/2016/04/worst-practices-should-be-hard.html https://www.haskellforall.com/2016/04/worst-practices-should...