DEV Community

Simple libraries do not guarantee simplicity - Rethinking popular NodeJs libraries

Michael Z on August 14, 2019

Originally posted at michaelzanggl.com. Subscribe to my newsletter to never miss out on new content. So often I see people architecturing their ...
Collapse
 
gypsydave5 profile image
David Wickes

At the end of the day, we want to build applications and be confident about the code we have written.

Hmm

  • How confident are you about how any of these frameworks work?
  • How confident are you that they will be supported next year?
  • How confident are you that your requirements for next month will be, or even can be, met by these frameworks (hint: you do not know your requirements for next month)?

Simple

No, they are not simple. They are easy. Dig under the superficially simple surface and I'll guarantee that you'll be confronted with complexity, probably incidental complexity. It looks simple because the complexity is hidden away, rather than explicit. Like hiding your dependency graph in an inversion of control container. It's better to try to address and simplify that complexity rather than shoving it under the carpet and hoping that nobody notices.

Collapse
 
michi profile image
Michael Z • Edited

Sure there are some tradeoffs to be made. But I'd say frameworks cover more than one use case, so when requirements change (and they will), there is a good chance the framework already provides a solution for it, or provides a way to override its behaviour. At least working with Laravel, this has been a very pleasant experience. If I wanted to understand how things worked internally I had a look into the source code.

Now if you are not using a framework you'd likely have a big task ahead once requirements change, depending on how coupled the code is. Of course, if you are very experienced this should be not a big problem, but at least for me, it took me a framework to teach me about these things.


How confident are you about how any of these frameworks work?

No, they are not simple. They are easy. Dig under the superficially simple surface and I'll guarantee that you'll be confronted with complexity, probably incidental complexity

The point of my article was that if you are using one of these low level routing libraries, you should simply take a look at more high level frameworks and see if they can not already provide you with everything you need. But are you suggesting that even simple libraries like koa or hapi should be avoided?

Collapse
 
quii profile image
Chris James • Edited

There's lots I disagree with about this post that has been argued so much it seems hardly worth going over again. Just read

However

a clean architecture to keep everything together

What is a clean architecture to you? What does it mean? And why do I need to download someone else's code to get it?