Echo JS 0.11.0

<~>

tracker1 1769 days ago. link 1 point
This is just my $.02, but class-based models are just burdensome in practice and tends to come from a different mindset, usually those who are very experienced or comfortable with Java or C#. I'm not a hard liner either way, there are times where class syntax is incredibly useful with JS, usually where you need to bind context to events, however this is more of an exception to the rule so to speak and being pragmatic over purity.  For most logic work, functional workflows will be easier to comprehend and maintain over time.

While you can use this approach, I find that in practice, it's generally better to use plain/simple objects without any magic, and use immutable function libraries against those plain objects (and/or arrays of plain objects) for workflows/pipelines.  If you're using TypeScript, you can still do interface definitions for expected properties and the shape of said objects.

Once you go down the path of getters/setters you open yourself up to a level of mutation that's hard to account for in terms of testability and reliability.

JavaScript has a wonderful flexibility in terms of object construction with functional composition.  And while not strictly a functional language with full immutability features, the closer you stick to these conceptually, the less variance and trouble you will have in practice.