Question Details

No question body available.

Tags

javascript mvc node.js architectural-patterns clean-architecture

Answers (3)

April 28, 2026 Score: 2 Rep: 5,180 Quality: Low Completeness: 30%

I never use wildcard imports in a code that has to be maintained, because it obscures the dependency graph and power (and cohesion / coupling).

For example:

  • if a single member is imported, the import is an obvious candidate for decoupling
  • if too many members are imported, modules may need to be merged

Wildcard imports spread this information all over the file, making high level dependency analysis impossible at a glance.

April 28, 2026 Score: 1 Rep: 47,716 Quality: Low Completeness: 50%

The difference between UserService.findOrCreateUser() and findOrCreateUser() is that you change how that function is called. In the former, this points to UserService whereas this points to the global object in the latter. Whether that is a problem or not depends on how findOrCreateUser is written.

In JavaScript, the caller determines what this points to. Just bear that in mind. If UserService ever needs to maintain state, you'll want to import the whole object rather than individual functions.

April 28, 2026 Score: -1 Rep: 86,525 Quality: Low Completeness: 40%

The problem with import * isn't so much the calling code but the way you have written your service to expose lots of functions.

Try to encapsulate the functions and use an Object instead

import UserService from "./userService";
const s = new UserService(some, setup, params);
var u = s.findOrCreateUser(user);
u.updateUserConfirmToken();

With the functions tied to an object you no longer need to import each one individually