Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7008611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:45:27+00:00 2026-05-27T21:45:27+00:00

When working with lots of classes in a node module is the following mechanism

  • 0

When working with lots of classes in a node module is the following mechanism a good idea or is there a better way to achieve this?

// mymodule/core.js

module.exports = {
    ClassA: require('./class/ClassA'),
    ClassB: require('./class/ClassB'),
    ClassC: require('./class/ClassC')
}

// mymodule/class/ClassA.js

module.exports = function() {
    ...
}

// myapp.js

var core = require('mymodule/core')
  ;

var a = new core.ClassA();

The idea of the above is to keep classes in physically separate modules for maintenance whilst providing a namespace that is easy to use.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:45:28+00:00Added an answer on May 27, 2026 at 9:45 pm

    For me it is far clearer to have the modules you are using pulled in within the module using them. You can’t get around the fact that the module has these dependencies and it will be easier for someone else reading the code to see what is being used.

    Also if you ever wanted to reuse a single module you would have to also carry with it the core.js module–and all of it’s dependencies–from which your module is coupled.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I'm using Eclipse i work with lots of Java classes (especially when working
How much does the garbage collector affect performance when working with lots of objects
I'm working on a website that uses lots of png24 files, for transparency. I
I'm working on a big flash site with lots of component swfs and a
We're working with some very large config files which contain lots of Unity and
In a project I'm working on FxCop shows me lots of (and I mean
I am working on an application for android and we since we have lots
I'm working on a project that will have a single table holding lots and
For a project I'm working on I will have multiple servers and lots of
I have a pretty good non-OOP background. I've done lots of Visual Basic coding,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.