Re:The Sororicide Antipattern
by overgard on Thursday June 01, 2017 @04:01PM
(#14463960)
Does anyone actually do that (for loop to assign a bunch of variables)? To me that just looks like a really awkward way to fake inheritance. Whenever I see the term "composition" used, at least in my experience, it was just about embedding one object in another. For instance, in a game engine like unity where you do things by composition and components, you would do something like obj.GetComponent<Renderer>() or obj.AddComponent<Thing>() or whatnot. "Composition" still kept the boundaries very well defined.
[ Parent
| on HN ]
People do a morally equivalent thing in Javascript, on occasion. You can use Object.assign() to build an object's functionality from multiple unrelated objects. For example, see the section on concatenative inheritance here: https://medium.com/javascript-scene/master-the-javascript-in...
I'm sure this is a thing someone has decided was a good idea at one point. It can easily be done in other languages, too.
I wouldn't be surprised if someone, for example, decided to hijack PHP's `__call()` function to forward method calls to a component.
Rust has the similar Deref anti-pattern: https://github.com/rust-unofficial/patterns/blob/master/anti...