DEV Community

Discussion on: I am java developer trying to learn node.JS, where should I start.

Collapse
 
scott_yeatts profile image
Scott Yeatts • Edited

Remember to simplify!

Taking the time to work with simple JavaScript for a while is a good idea that others have suggested, but it scales too.

Many things that you might use multiple files to express in Java can be expressed in one file in node.

For example, when I ported a Java service to node, it had separate files for each class, and a class for each 200 return value, a class for each error, 2 commandhandlers/controllers etc etc.

In node it was the express server in one file. The router in a separate file and then a controller file that was essentially an Enum (using Java-ese) that defined all the functions for each route on the API and any helper functions.

Java-brain will make you want to over-complicate a bit. That complication is good in very large teams that might need to have one person working on one class and another person working on the controller, and another person working on the Spring implementation all in parallel. It forces you to slow it down and think it through to avoid side-effects on your teammates!

You CAN split out a node application in a similar way, but really as you are learning, KISS is your friend when trying to translate Java knowledge into JavaScript.

Hope that helps!