6

This is Node.js FYI

Exporting a single class from a file called util.js. This class only has static methods. Each method is a util function. No fucking way of importing a single method. Class abuse?

Comments
  • 2
    Depends on cohesion of methods, size of class
  • 1
    var { methodName } = require("./util.js");
  • 1
    @craig939393 It's not like they depend on each other in any way, and most of them have nothing to do with each other.

    @theabbie I failed to mention that we're using ES6 imports which makes that impossible.
  • 3
    This is code smell and would not pass my code review.
  • 1
    Maybe it shouldn't be a class anymore then? Nice of node.

    I mean... If it is all static, one class, so one 'instance' / state..

    Why you want this?
  • 1
    Class abuse yes. If all functions are static, might as well just exported that function instead of creating a class.
  • 2
    @rooter @abrd17 Precisely. I'm not the one who wrote this...
  • 1
    @ScriptCoded people lie. Violence is an option!

    I don't know which ide you're using but pycharm for example fixes everything when you do right-click move class to file. All imports fixed. I don't know how good it is of their other IDE's. But when it comes to refactoring it rocks
Add Comment