Skip to main content
34 votes

C# namespace and class naming convention for libraries

There is a nice document that contains a lot of rules that you should follow to be in line with Microsoft: Framework Design Guidelines. One thing that you should change: Do not name classes as their ...
nvoigt's user avatar
  • 8,445
12 votes
Accepted

C# namespace and class naming convention for libraries

It's very difficult to determine how effective your naming strategy is in isolation from the rest of your code. The namespace should give some idea where it fits in the broad structure of your ...
richzilla's user avatar
  • 1,123
11 votes

C# Namespace Ordering Coding Convention

When dealing with style, it is always more useful to take either an official style if one exists, or to use the one commonly adopted by the community of developers writing in a specific language. You'...
Arseni Mourzenko's user avatar
10 votes

C++ namespace name isolation

Your approach is not technically wrong (except a minor detail, see footnote) but it goes against established usage patterns and obfuscates code. I.e. it lowers readability and increases the likelihood ...
besc's user avatar
  • 1,163
10 votes
Accepted

C# Namespace Ordering Coding Convention

How would you determine the importance? The simplest way of ordering the usings is to apply an alphabetical order; However, it is often useful the make the difference between usings pointing to the ....
Olivier Jacot-Descombes's user avatar
9 votes
Accepted

C# Names of Namespaces with version suffix

When the documents mention second-level, they're referring to the section of the namespace indicated as (<Product>|<Technology>). The product or technology should be version independent. ...
Neil's user avatar
  • 22.8k
9 votes
Accepted

Am I using namespaces wrong?

Am I using namespaces wrong? Wrongly. It's an adverb. And the answer is probably. In use cases, which would you prefer? There are several reasonable tests. Is one easier to read, easier to say, ...
Useless's user avatar
  • 12.7k
9 votes
Accepted

Are namespace constructs like 'using std::string' unacceptable also in .cpp files?

using directives are certainly acceptable in *.cpp files when C++ authorities like Herb Sutter and Bjarne Stroustrup explicitly say so in their published Core Guidelines: Use using namespace ...
Christian Hackl's user avatar
8 votes

C++ namespace name isolation

Looks like a wrong approach, for several reasons: The things that you don't want to be "visible" to outside, should not go into headers. Instead they go into anonymous namespace in the source file. ...
BЈовић's user avatar
  • 14.1k
8 votes

Should I use other framework's namespaces in my code?

Namespaces have two main functions: Provide unique names for symbols; Group related symbols. For the unique names, putting your symbols in someone else's namespace is a big NO NO. As community of ...
Kasper van den Berg's user avatar
8 votes
Accepted

Why would you have a different namespace for each folder in a C# project?

The whole point of a namespace is that type names within the namespace are unique. So this is okay: namespace A { class Foo { } } namespace B { class Foo { } } This allows ...
John Wu's user avatar
  • 26.9k
7 votes

C# namespace and class naming convention for libraries

It's been a while since I've worked with C# or the .NET ecosystem so I can't say what the current recommended best practices are. I'd recommend a change to your names like this: Company Company.Text ...
FrustratedWithFormsDesigner's user avatar
7 votes
Accepted

How can I cleanly handle deeply nested namespaces in C++?

this creates an entirely new issue where there are two separate hierarchies — one for namespaces, and another for the file system. That's not an issue at all though, it's perfectly normal. ...
Useless's user avatar
  • 12.7k
7 votes
Accepted

C++ Is it okay to use nested classes as a way to namespace derived classes?

This is a very bad idea, because it breaks the Open/Closed Principle: Classes should be open for extension, but closed for modification. This means that it should be easy to "extend" your ...
Christophe's user avatar
  • 80.6k
6 votes

C++ namespace name isolation

What problem do you want to solve? That is completely unclear. As for your code, if you were a junior assigned to me, I would say: Your approach doesn't hide implementation details at all - they are ...
Sjoerd's user avatar
  • 2,966
5 votes
Accepted

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

Why not its own file within the namespace it belongs? For example, if I'm working on Legal Matters in my Domain project and I have an enum of MatterStatus, I'd place the enum with a MatterStatus.cs ...
jleach's user avatar
  • 2,682
5 votes

C# namespace and class naming convention for libraries

Using the same name for the namespace and the class inside it is problematic. If the namespace contains more than one class, why would other classes be put there? it doesn't feel right, because the ...
Arseni Mourzenko's user avatar
5 votes
Accepted

Using a macro for a libraries namespace?

This technique is sometimes used to handle transitive dependencies on header only libraries. It is not generally a best practice. The problem: I am writing a C++ library. I put all of my declarations ...
amon's user avatar
  • 135k
5 votes

Refactor namespaces in a library while keeping backwards-compatibility

How do I keep my library backwards-compatible? The short answer is: you can't. If you move a type from one namespace to another, your choices are to manually create a delegation class in the old ...
David Arno's user avatar
  • 39.5k
4 votes
Accepted

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

In Extensible Markup Language (XML) 1.1 (Second Edition) Section 3.1 Start-Tags, End-Tags, and Empty-Element Tags, it's called an "empty-element tag". If you were using XML and needed the formal term, ...
Thomas Owens's user avatar
  • 84.2k
4 votes
Accepted

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

I have done it and it's possible, though there are a few pitfalls around autoloading to consider. I described the approach in a blog post: PHP: Using class_alias to maintain BC while moving/...
Fabian Schmengler's user avatar
4 votes

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

To my knowledge, importing a complete package into the current namespace is not frowned upon as much in Python and Java as it is in C++. I think this has to do with how namespaces are integrated into ...
Bart van Ingen Schenau's user avatar
4 votes

C++ namespace name isolation

If you really want constructive feedback on this approach, it would have been better to show some actual code that you think benefits from it. Then we'd have something concrete to discuss rather than ...
Useless's user avatar
  • 12.7k
4 votes

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

Yes, I believe that is the standard approach if you want to have PUBLIC (namespace) variables. But to make private namespace variables, the usual approach is to use a closure (example using closure ...
Lewis Pringle's user avatar
4 votes
Accepted

Should namespaces within a single project act as boundaries?

The short answer is that no there are no rules and its up to the developer as shows by the fact that the language itself doesnt care how you go about dealing with namespaces. That being said, the ...
TurtleKwitty's user avatar
4 votes

How can I cleanly handle deeply nested namespaces in C++?

One way to handle it: Don't do it. In your example, you could have a namespace game_name::server and leave it at that. Don't reuse names for top level objects obviously. But they are confusing ...
gnasher729's user avatar
  • 47.5k
3 votes

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

If you have enough code that you want to re-use, create a company namespace. You can organize diffrent code into different libraries as well so that you don't need to include all your company's shared ...
fstam's user avatar
  • 212
3 votes

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

The using namespace directive is useful when you have namespaces that identify your project. Say you have a project that uses the developerIdentifier::projectName namespaces. That project has a class ...
Wes Toleman's user avatar
3 votes

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

Yes, certainly there are valid uses for the using namespace-directive. For example, if you want to use user-defined literals, there operators must be in-scope, so: using namespace std::literals; Or ...
Deduplicator's user avatar
  • 9,131

Only top scored, non community-wiki answers of a minimum length are eligible