3 ms·
Honestly, I'm not a big fan of Class-based design... I really feel that JS lends itself much better to a system of functions with composition. You can create a
by tracker1 12y ago
Honestly, I'm not a big fan of Class-based design... I really feel that JS lends itself much better to a system of functions with composition.
You can create a number of stand-alone functions that take an object that is operated against as a parameter and return a value, or modified object. You can now test these independent functions as modules without a lot of distractions that come from side effects and state. With that in place you can bind those functions into a composed object (state), and use that in the rest of your application. You have composition, encapsulation and testable code that is just plain difficult to reason about when you are using Class-based inheritance and trying to test against it.
I actually love JS... it has its' quirks, but I find the flexibility it offers to exceed what most other languages offer for most tasks. Using small function libraries and modules, I find that I can orchestrate much larger operations far more easily than can be done with other systems (usually). All of that said, I also love C#, and use it very differently.
People should stop trying to walk in water, and just swim.