8
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.
Coupling ...
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 ...
5
votes
Accepted
"Hard coded" vs. configuration files for values in libraries? (code organization question)
There is no best practice or general rule. It is situational and depends on how often this data needs to change, how difficult it is to change, and team preferences.
Keeping this information in config ...
5
votes
Which is a good way of separating and organizing layers and subdomains code, one that highlights and facilitates a clean architecture?
If your goal is to keep related things together, here is an article of mine about packaging. In short:
Packages should never depend on sub-packages.
Sub-packages should never introduce new concepts, ...
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 ...
4
votes
Accepted
Managing error code and error message mapping
Should error codes be named per-struct
The granularity of error codes should fit to the existing requirements of the system. Make them as granular as needed to display meaningful error messages, or to ...
4
votes
Accepted
Folder structure for a C project
Both is possible, so if you find any reason to use one approach instead of the other, go ahead.
I would use the second approach (top level directories are core, module1, module2, etc.) if the ...
4
votes
Accepted
Where to put interface files for mocking aka what are best practices for organizing interfaces in a C#/.NET Core project with NSubstitute, Moq etc.?
Decisions like this are usually best guided by the Principle of Least Astonishment: What pattern will other developers recognize and understand quickly?
First, C# projects have a very common ...
3
votes
What are some methods of storing personal notes alongside code?
I'll just comment on your comments.
foo = get_foo(bar, boom); // Actually returns a proto-foo, not a foo
Refactor, rename.
foo += 1 // Alice says this is to avoid the lochness bug
Perfectly good ...
3
votes
What are some methods of storing personal notes alongside code?
I read code with my fingers. So I've always solved this problem by keeping my own local copies of the code that I never publish. Lets me experient and say what's on my mind quickly. Sure it means I ...
3
votes
How to organize top level scripts in Python projects, especially for interactively developing
I am using a similar structure in some of my projects and I prefer to keep these top level scripts in a subfolder so that the project root doesn't get cluttered.
This works fairly easy without ...
3
votes
In C#, is it reasonable to use a #region when I need several members to implement a common interface?
I know that lots of people hate #regions in C#
Whenever #region gets mentioned, people immediately jump on the bad practice bandwagon. And it's true that #region can be abused to hide monolithic code....
3
votes
Accepted
What are some best practices for team structure around Mobile and Desktop apps?
The decision to use a single repository for both the Mobile and Web versions or to use multiple repositories should depend heavily on the release cadence of the two versions of the product.
If it is ...
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
Separating Plotting and Computation Logic in Scientific Computing MVC App
I would go for solution #5 - standard Dependency Injection:
Either at construction time (in case the computation is implemented in a class), or when calling the function, the computation logic takes ...
3
votes
Accepted
Relative merits of monolithic repository over multiple smaller ones
There are two questions in your post, and they should IMHO be answered separately. Assumed one is going to create a somewhat "large" software system using C++,
should one create different, physically ...
3
votes
Accepted
How might encapsulated source be broken into into multiple files?
The result of your suggested code organization does logically not differ from
a single header file mystruct.h with the struct itself and all function declarations, plus
a single code file mystruct....
2
votes
Accepted
Organizing Python functions into a module or class
Also, is it acceptable to organize these functions in a class, or should they just remain as top-level functions in the clustering module?
The usual advice is use a class when you have common data, ...
2
votes
DRY Violation for Logical Code Organization and Readability
When to introduce functions
You're looking at that question from a code-centric view, deciding how to organize it mainly from the "repetition" viewpoint. When I started programming back in the 1970s, ...
2
votes
Accepted
Best practice for organizing build products of dependencies and project code in your repo source tree?
Many build tools nowadays support "out of source" builds, where the intermediate and final build artifacts are stored in a location outside of the source tree. This is comparable to your ...
2
votes
Where to put the code that searches objects in a complex hierarchy?
Based on what you've said (and not knowing the language), I'd probably do something like
Create an interface ISearchable, containing a single method: Optional<T> satisfies<T>(<...
2
votes
"Hard coded" vs. configuration files for values in libraries? (code organization question)
Is it likely to change without a feature change? (Within my lifetime we have seen new types of fruit, and I have also encountered fruit while traveling that does not appear to exist here) Config ...
2
votes
Where are all the small functions supposed to go in XP?
XP is a fairly loose collection of best practices and ideas, with the underlying idea to take them to the “extreme”, i.e. to take them seriously and practice them fully.
Keeping functions small is ...
2
votes
C++ Is it okay to use nested classes as a way to namespace derived classes?
C++ supports nested classes, so from a purely syntactically point of view, you might do this.
Not having to write #include HondaAccord.h can be achieved by bundling includes in one one header file ...
1
vote
Where are all the small functions supposed to go in XP?
You are looking for an organizing principle. Unfortunately there isn't a one size fits all answer here. However, there are options to consider.
You mentioned one: Alphabetize. This helps when code is ...
1
vote
"Hard coded" vs. configuration files for values in libraries? (code organization question)
I suspect you may realize that there is no one-size-fits-all answer here. I'm going to do my best to address the related concerns so that you get an idea on how to judge this on a case-by-case basis.
...
1
vote
In C#, is it reasonable to use a #region when I need several members to implement a common interface?
As with other code style issues, this is subjective and hard to make good universal claims. IEquatable had far fewer members and doesn't muddy readability as much as IEnumerable, for instance, but ...
1
vote
How do I organize my REST API codes along with the codes for generating the website?
There are two major ways of keeping your codebase DRY:
Create your web-application as a Single Page Application (SPA): The webserver just gives out a web-application written in JavaScript that runs ...
1
vote
How do I organize my REST API codes along with the codes for generating the website?
Assuming you're not going the route of having the website use the rest-api (it's a typical approach for SPA web frameworks like Angular or React), then you can move the logic into a common "Service ...
1
vote
DRY Violation for Logical Code Organization and Readability
When you read about DRY, there is no absolute prohibition of repetition, you have to look at the cost.
If the same calculation is performed in three different places miles apart, and the calculation ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
code-organization × 112c# × 15
.net × 10
c++ × 9
organization × 9
architecture × 7
javascript × 7
python × 7
c × 6
project-structure × 5
design-patterns × 4
php × 4
unit-testing × 4
coding-style × 4
code-quality × 4
winforms × 4
file-structure × 4
design × 3
programming-practices × 3
git × 3
version-control × 3
mvc × 3
clean-code × 3
source-code × 3
visual-studio × 3