In my app, obviously I need objects. In C#, I would create a class and instantiate it to get an object.
In Node.js however, I have two options:
- Creating a 'class' in a Node module of it's own, and later
requireing and instantiating it (like I would do in C#).
- Creating an object in a Node module of it's own, and using it
requireing it directly.
I'm trying to decide what the better approach in general is.
I'm leaning strongly towards approach
1, because it lets me instantiate the desired class anytime I want, instead of using a global singleton.
On the other hand, maybe it feels like the better approach simply because I'm used to it, coming from C#. Possibly I'm just trying to do C# in JS?