4 ms·
Haha you wouldn't like Node then :)
by fks 13y ago
Haha you wouldn't like Node then :)
- moron4hire 13y agoIt is a thing that bothers me a lot about Node. I much prefer the .NET style of namespaces over direct file importing, which I could have sworn C taught us was an antiquated way of doing things. They try to get around it with some goofiness of "partially loaded files" in the case of A-requires-B-requires-A, but it smells like a hack and I avoid it at all cost. That said, it's not necessarily required. You can make any of your module files export only one function, a function that defines a class. This is the preferred pattern in most programming languages. I then use dependency injection to propagate my state around. And that's generally the case in any programming language: if you're thinking of a singleton, dependency injection is the answer.
- fks 13y agoMy next post is on class design in Node. Keep on the lookout, would love to get your feedback on it.