Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

Namespaces are a language feature of many programming languages, allowing local reuse of class and variable names.

0
votes
1answer
42 views

C# Separate Online Store into Different Solutions and Nugets

I am creating an Online Shopping Cart store. It is built through Net MVC Core. There is a Front End View website: html, css, razor. Then we have backend code design for Customers: including shopping ...
2
votes
1answer
88 views

Should namespaces within a single project act as boundaries?

When working within a single project that contains multiple namespaces, should these namespaces be treated as boundaries? Or is it acceptable that any namespace can access any other namespace? For ...
1
vote
1answer
57 views

How can I avoid using global variables in simple Javascript SPA?

To learn Javascript I am building a simple Single-Page Application. It is a basic slideshow app that needs only to process some basic settings and execute some behaviors. The basic structure of my ...
-1
votes
1answer
169 views

Using a macro for a libraries namespace?

In some code bases (such as hydra, and thrust's tuple implementation) I see namespaces defined entirely with macros. It appears the reason for this is so that you can configure the namespace to your ...
0
votes
4answers
237 views

When it isn't right to add types to a well known namespace?

For the purpose of writing a library, I found to be nice to add types to some well known namespace. Example: I've written a couple of extension methods for BinaryWriter and naturally put them in ...
5
votes
2answers
361 views

C# Names of Namespaces with version suffix

In official Microsoft docs: ✓ DO use a stable, version-independent product name at the second level of a namespace name. But in Reference Source, the following namespaces ends with Version: ...
3
votes
2answers
147 views

Is there a valid use case for the using namespace directive?

I looked trough some of my older code and found that I was using the using namespace directive. From what I read in a lot of google results, it seems that it is never a good idea to use this. Is there ...
3
votes
2answers
335 views

Avoiding conflicting namespace and class name

Say I am developing a Calculator application. It has one class called: Calculator. Therefore my namespace structure would look like this: MyCompany.Calculator.Core.Calculator Unfortunately, this ...
1
vote
3answers
105 views

Is it considered a bad practice to import symbols in bulk to a global namespace irrespective of the programming language?

In the C++ community it is considered an extremely bad practice to type: using namespace something; in the scope of the file for any reason, even if the project size is only a few hundred lines at ...
4
votes
2answers
168 views

Is there an Ideal way of storing namespace-related elements?

In the title, with namespace-related elements, I refer to Enums, Delegates and other elements that do not belong to a single class, but to the whole namespace, or application. I know that I can cram ...
-3
votes
6answers
778 views

C++ namespace name isolation

It's been considered for a reason, that using for namespaces/names is side-effect-prone, and generally, fully qualified names should be preferred. I've come up with an approach on that, which I ...
22
votes
4answers
7k views

C# namespace and class naming convention for libraries

I'm building libraries with various small utility functions in C#, and trying to decide on a namespace and class naming convention. My current organization is like this: Company Company.TextUtils ...
4
votes
1answer
321 views

Impacts of using class_alias() to maintain backwards compatibility in PHP

Scenario: An open-source PHP project that has existed for several years has too many classes in the main namespace that we want to refactor some of them into another namespace, but we have a widely ...
2
votes
0answers
137 views

How to structure the project folders of my application's service layer?

I want to know how to structure my Service Layer I have thought about something like that: Assembly called SomeNamespace.Service. Have a seperate folder for each problem domain (SomeNamespace....
1
vote
2answers
987 views

Is including headers inside a namespace always a bad idea?

The replies in this post come very strongly against including headers inside a namespace and Doxygen is confused if that is done (which suggests that its team did not consider that usage either). I ...
0
votes
1answer
116 views

What terms are used to differentiate the two xml forms, “<element></element>” and “<element/>”?

I'm writing a boolean that will toggle between these two forms for writing markup into my strings, but I do not know what I should name my boolean. bool setMarkupForm(bool markupForm); Is not ...
0
votes
3answers
162 views

Load values from txt to variables in namespace

I am currently working in an aleady developed C++ project. The existing files are the following: -main.cpp -HydroModel.cpp -ODESys.cpp -HydroModel.hpp -ODESys.hpp -ODESysSol.hpp In the file ...
3
votes
3answers
493 views

namespaces and header guards with naming conflicts

C++ has namespaces to prevent collisions of things with the same name. Header guards serve a different purpose. They prevent includeing the same header twice. However, they can suffer from the same ...
2
votes
1answer
71 views

In what namespace would I place “Doers”

This might sound weird and probably is, but I am struggling to find a good place where to place what I will just call "Doers" for lack of a better name. Basically, my project currently has these ...
1
vote
3answers
856 views

Should class names reflect namespace name?

Is it generally considered good practise for a class name to reflect the namespace name it exists under, or should the namespace name implicitly be considered part of the class name? For example, ...
4
votes
1answer
115 views

Regarding the Organization of Bit Shifting Utility Functions in C++

I am developing a project in C++ that deals with converting an ASCII hexadecimal string representation into binary. The class also has utilities in it for extracting info from the string. Right now ...
2
votes
2answers
789 views

Using a domain name as C++ namespace

What would be a good system to use domain names as C++ namespaces in order to avoid name clashes between developers? The idea appears to be popular in the Java world. We cannot use namespace example....
3
votes
3answers
3k views

Same class and namespace name

I have a problem how to go about naming my namespaces and classes. I already figured they shouldn't both have the same name, as it causes all kinds of problems. Most notable problem for me is that I ...
0
votes
0answers
61 views

Namespaces for a custom XML like language: URIs or not

I am working on an XML like language that features a namespace system also. Now my question is: Should I use URIs as namespace names too (1) or should I follow the naming of java/.net/php namespaces (...
0
votes
0answers
57 views

Code architecture for separate apps facilitating the same process

So I am at a cross roads with deciding on my integration strategy for a few of our business apps that play a role in a larger process. Being the only developer and never having to do this before leads ...
2
votes
2answers
144 views

Why do we need namespaces when making XML serialization?

I know this might be a very basic question, but I'm new to XML serialization and spent hours trying to read different pages. PS: this is a programming language independent question.
5
votes
1answer
5k views

Importing namespaces inside another namespace

I generally like to organize classes I make into modules by using namespaces, and I also don't go more than 2 namespaces deep but it's still painstakingly hard to fully qualify everything. I've ...
3
votes
1answer
340 views

“Vendor” name changes when the vendor name changes

PHP (PSR-2, anyway) recommends using the vendor name as the root namespace for projects. At face value, this seems to mean we should use the current name of our company. But I work for an enterprise ...
6
votes
3answers
3k views

C++ Extensible namespaces - how to force declarations back into global namespace

It is good programming style to include all necessary dependencies in a header that references them. Often this includes declarations that are placed in the STD & global namespaces (like cstdio). ...
2
votes
0answers
450 views

Why aren't there traditional namespaces in TypeScript? How do I group classes without them?

"Traditional" namespaces in the sense that Java, C#, and PHP use it. Spaces to organize related classes and sub-namespaces that span across multiple files. How do I rewire my brain to think without ...
8
votes
1answer
4k views

static globals and anonymous namespaces in C++

Why did C++ make any distinction between static globals (internal linkage) and symbols in an unnamed namespace (external linkage, but no way to refer to it from outside anyway), when introducing the ...
3
votes
1answer
96 views

Namespace by topic or by purpose? [closed]

The project I'm working on has quite a few classes. These classes can be grouped in two different ways. I'm trying to decide which grouping is best as for namespacing. Currently I a set of user facing ...
15
votes
4answers
3k views

Semantically more appropriate package name than `util` for the following things?

As a strawman consider the package java.util it is a dumping ground for various classes that in most cases do not share anything in common other than the person that put them there was lazy or ...
5
votes
1answer
2k views

Nested classes via a getter (to emulate namespacing)

So, we all know that ES6's introduced syntax is definitely sugar over what we've been doing, previously. That being said, we still don't have namespaces (which would be nice...) The problem that I'm ...
1
vote
1answer
145 views

Clojure NameSpace Design

I am new to Clojure and trying to get a handle on organizing a project's namespaces. I am working on a solver for the knapsack problem. Currently, I have broken the modules into files, but everything ...
1
vote
1answer
1k views

Python, namespace vs module with underscores

I'm developing a project that uses several independent modules, but all related to the same project. However, I face this choice: module names with underscore vs. namespaces. For example there is ...
4
votes
2answers
501 views

Free Standing Functions in Global Namespace

When writing non-member, free functions, can they be placed in the global namespace so long as the signature specifies a namespace-scoped object? For example, in the code below, is "Example 2" ...
4
votes
1answer
714 views

When to use nested classes and when to use namespaces?

I have really never made use of namespaces, and am considering them at the moment. My situation. I have a class Reverb. It contains as members instances of other classes, declared in the same header ...
0
votes
1answer
1k views

Best practice for using namespaces in my PHP libraries

I've been using a tiny and neat caching library on my projects, but I realize that "Cache" is a very generic name and it's easy to get a collision when using it in large projects. Also, I would like ...
12
votes
1answer
1k views

Naming convention for iOS/OSX open-source projects

Not always but most of the time, you will find iOS or Mac OS X open-source projects with names starting with the initial letters of the author first and last names. If a project were to be authored by ...
3
votes
1answer
172 views

How to tell that a Javascript code already needs AMD (RequireJS, …)?

At some point code is complicated less if you introduce a new abstract than if you continue as it was. Some trigger should fire in a head of a programmer. Like, I was coding fine, but now I've added ...
4
votes
2answers
286 views

Why do XML namespace URIs use the http scheme?

A XML namespace should be a URI, but it can use any URI scheme, including those that are not URLs. Then why do all widely used XML namespaces use the http scheme (e.g. http://www.w3.org/XML/1998/...
2
votes
2answers
815 views

With AMD style modules in JavaScript is there any benefit to namespaces?

Coming from C++ originally and seeing lots of Java programmers doing the same we brought namespaces to JavaScript. See Google's closure library as an example where they have a main namespace, goog and ...
3
votes
1answer
875 views

How can I identify a namespace without using a string literal?

My team has a lot of IOC conventions that look something like... if (type.Namespace == "My.Fun.Namespace") { // do stuff } Of course, maintaining this kind of thing becomes brutal after awhile, ...
0
votes
1answer
3k views

How to use namespaces to separate interface from implementation, in c++?

As far as I can tell, you can make your interface known to others by providing your .h file. Your .cpp is the implementation. Then they can see the function names, the parameter types, the return ...
7
votes
1answer
2k views

Separate namespace just for exceptions?

I was doing a code review and came across something odd which I've never seen before. The developer decided to create a sub-namespace just to contain all the assembly's exceptions. I thought I had ...
0
votes
0answers
1k views

Ruby module namespacing advice

in my current project have: module Stats class Site ... end class Product def initialize(product_id) @product_id = product_id end end class Profile ... end end ...
2
votes
6answers
2k views

Nested Classes or Namespace

Why do need namespaces when we have nested classes. What can be done through namespaces, can also achieved through nested classes. so I don't understand the reasoning of having namespaces ?
18
votes
1answer
14k views

Pros and cons of namespaces vs include/require in PHP?

I recently started using namespaces in PHP. When I first saw them, I thought that their syntax was ugly and I'd never use them. However, I created an autoloader (spl_autoload_register) that makes it ...
4
votes
2answers
155 views

Should package structure closely resemble class hierarchy?

Pretty simple question. Should package structure closely resemble class hierarchy? If so, how closely? Why or why not? For instance, let's say you've got class A and class B, plus class AFactory ...