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

  • Home
  • SEARCH
  • 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 137275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:04:50+00:00 2026-05-11T07:04:50+00:00

On the project we are trying to reach an agreement on the namespace usage.

  • 0

On the project we are trying to reach an agreement on the namespace usage. We decided that the first level will be ‘productName’ and the second is ‘moduleName’.

productName::moduleName 

Now if the module is kind of utility module there is no problem to add third namespace. For example to add ‘str’: productName::utilityModuleName::str – to divide space where all ‘strings’ related stuff will go.

If the module is the main business module we have many opportunities and almost no agreement.

For example

class productName::mainModuleName::DomainObject 

and

class productName::mainModuleName::DomainObjectSomethingElseViewForExample 

can be both at

namespace productName::mainModuleName::domainObject class Data class ViewForExample 

Why should we create inner not private classes and not namespaces? Why should we create class where all methods are static (except cases when this class is going to be template parameter)?

Project consist of 1Gb of source code. So, what is the best practice to divide modules on namespaces in the c++?

  • 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. 2026-05-11T07:04:50+00:00Added an answer on May 11, 2026 at 7:04 am

    What namespaces are for:

    Namespaces are meant to establish context only so you don’t have naming confilcts.

    General rules:

    Specifying too much context is not needed and will cause more inconvenience than it is worth.

    So you want to use your best judgment, but still follow these 2 rules:

    • Don’t be too general when using namespaces
    • Don’t be too specific when using namespaces

    I would not be so strict about how to use namespace names, and to simply use namespaces based on a related group of code.

    Why namespaces that are too general are not helpful:

    The problem with dividing the namespace starting with the product name, is that you will often have a component of code, or some base library that is common to multiple products.

    You also will not be using Product2 namespaces inside Product1, so explicitly specifying it is pointless. If you were including Product2’s files inside Product1, then is this naming conversion still useful?

    Why namespaces that are too specific are not helpful:

    When you have namespaces that are too specific, the line between these distinct namespaces start to blur. You start using the namespaces inside each other back and forth. At this time it’s better to generalize the common code together under the same namespace.

    Classes with all static vs templates:

    ‘Why should we create inner not private classes and not namespaces? Why should we create classes where all methods are static’

    Some differences:

    • Namespaces can be implied by using the using keyword
    • Namespaces can be aliased, classes are types and can be typedef’ed
    • Namespaces can be added to; you can add functionality to it at any time and add to it directly
    • Classes cannot be added to without making a new derived class
    • Namespaces can have forward declarations
    • With classes you can have private members and protected members
    • Classes can be used with templates

    Exactly how to divide:

    ‘Project consist of 1Gb of source code. So, what is the best practice to divide modules on namespaces in the c++?’

    It’s too subjective to say exactly how to divide your code without the exact source code. Dividing based on the modules though sounds logical, just not the whole product.

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

Sidebar

Related Questions

im programming a project and im trying to apply multitier architecture. Right now ive
I'm working on a project that is trying to use context-free grammars for parsing
For a project I'm currently working on am trying to reach the following: I
I installed the Rails installer. Now I'm trying to create a new Rails project.
I'm trying to do some unit testing on a project that unfortunately has high
I'm creating a Django project that will be used by multiple domains, and the
I have a .net mvc 4 webapi project that I'm trying to pass an
I'm working on a project and trying to use JavaScript for validating all inputs
I'm working on a project and trying to render some images sitting under the
I am working on a VB.Net project and trying to get it to pull

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.