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 ...
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 ...
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'...
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 ...
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 ....
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. ...
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, ...
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 ...
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.
...
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 ...
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 ...
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
...
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.
...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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, ...
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/...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
namespace × 98c# × 29
c++ × 28
naming × 14
php × 8
.net × 8
design × 7
javascript × 6
xml × 5
packages × 5
modules × 5
class × 4
project-structure × 4
architecture × 3
object-oriented × 3
programming-practices × 3
libraries × 3
code-organization × 3
python × 2
coding-style × 2
refactoring × 2
interfaces × 2
language-agnostic × 2
coding-standards × 2
abstraction × 2