DEV Community

Discussion on: Learn and use Composition in JavaScript and TypeScript

Collapse
 
greggman profile image
Greggman

This looks like it has issues compared to the composition I'm used to.

These are not real examples. A real composition each piece being composited will have local state and that local state will be per instance. In other words, I need a steer the has a this.direction and I need a run that also has a this.direction and those should not be the same direction because there can be 1000s of things to composite and there would be no easy way for programmers to know they're all using direction in the same ways.

Collapse
 
koresar profile image
Vasyl Boroviak

Well, you've just dissed Martin Fowler's definition of "code smell".

"code smell" != "certainly bad code"

Collapse
 
greggman profile image
Greggman

By any definition of code smell, having to look at the internals of every function you composite to make sure it's not going to conflict with any other function is the very definition of stinky code. Gees

Collapse
 
koresar profile image
Vasyl Boroviak

IMHO, 1000s of things to compose is a code smell.

Collapse
 
greggman profile image
Greggman

Well you just dissed every Unity game that's shipped and all Unity devs so I guess it's you against them. Every Unity game is 1000s of things to compose.

Thread Thread
 
softchris profile image
Chris Noring

I wonder if this is a typical thing in games particularly. Have you seen this kind of composition elsewhere? I'd appreciate any code samples that show the kind of composition you describe.

Some comments have been hidden by the post's author - find out more