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 3428818
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:00:19+00:00 2026-05-18T07:00:19+00:00

Would it be considered bad practice to use sub-namespaces for purely organizational purposes? For

  • 0

Would it be considered bad practice to use sub-namespaces for purely organizational purposes? For example:

namespace vehicles
{
    namespace cars
    {
        // Stuff here
    }

    namespace boats
    {
        // More stuff here
    }
}

I can see how this would be a problem on large projects, because it would be inconvenient to type vehicles::cars::function a lot. What about small projects, though?

  • 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-18T07:00:20+00:00Added an answer on May 18, 2026 at 7:00 am

    Why would it be less inconvenient to type vehicles::cars::function a lot in a small project?

    Remember what purpose namespaces are supposed to serve. They are supposed to avoid name clashes, and not much else.

    If you invent such a convoluted namespace structure that I’m tempted to just put a few using namespace ...‘s at the top of every file, then it defeats the purpose of namespaces.

    It also doesn’t really tell me much I didn’t know already. What are you going to put in your boats namespace that I wouldn’t know from the name alone was a boat? Am I going to need the clarification that “this belongs with the boats” on anything in the namespace? Most likely not, and then there’s no point in having the namespace.

    In general, don’t ask what problems there are with using any language feature until you’ve found out what the advantages are. Every feature needs to justify itself. So what problem would your proposed namespaces solve?

    If it wouldn’t solve a real, actual problem, then it is a bad idea, regardless of anything else.

    I always think it’s instructive to look at different language’s standard libraries.

    .NET uses deeply nested namespaces with long names. The full name for a simple dynamic array is System.Collections.Generic.List<T>.

    As a result, no-one ever uses the namespace. Everyone just puts a using System.Collections.Generic at the top of every file that needs to use a List.

    And because of this, you’re in trouble the moment you encounter another List class. You’ll want to do the same with that, and voila, you have two List classes clashing.

    C++ uses a very flat namespcae structure, where namespaces also have very short names.

    The equivalent class in C++ is simply std::vector. As a result, people generally type out the namespace prefix, and so, when I add another vector class to my project, *it works’. There are no name clashes, because I use the std:: prefix when I want to refer to the standard library vector.

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

Sidebar

Related Questions

Would this be considered bad practice? unless Link.exists?(:href => 'example.com/somepage') Domain.where(:domain => 'example.com').first.links.create(:href =>
Would it be considered best practice to use a single template that changes it's
Would this code be considered bad practice: <div id=sidebar> <% =DisplayMeetings(12) %> </div> This
Would it be considered a bad practice to nest a private static class inside
Is it considered bad practice to pair function names with classes? For example in
Possible Duplicate: Is it considered bad practice to use non-standard HTML attributes? Hi folks,
Would it be considered bad practice to have a viewmodel that has a property
Is it considered a bad practice to use optional parameters when using dependency injection
Possible Duplicate: Why is 'using namespace std;' considered a bad practice in C++? Every
Would you consider it bad practice to store various user data in a database

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.