22
votes
Small functions vs. keeping dependent functionality in same function
The problem you're dealing with is called temporal coupling
You're right to be concerned about how understandable this code is:
private func setupNodes() {
createNodes();
connectNodes();
}
...
10
votes
Small functions vs. keeping dependent functionality in same function
Separate functions, for two reasons:
1. Private functions are private for exactly this situation.
Your init function is public, and it's interface, behavior, and return value is what you need to worry ...
9
votes
Accepted
Should parameters of a method be in the same namespace as the class?
Should I move ClientQueryBuilder class to Service namespace?
No. You will end up with one giant namespace.
But I think the flaw in the logic goes deeper. You say that namespaces are a way of ...
9
votes
How to best to organize class and interface files?
Since an interface is abstractly similar to a base class, use the same logic you would use for a base class. Classes implementing an interface are closely related to the interface.
I doubt you would ...
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
Accepted
Writing quality code
Software patterns are mostly about vocabulary. They give software developers a language by which they can communicate high-level design concepts.
But patterns are not a design methodology; if you'...
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, ...
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 ...
4
votes
Small functions vs. keeping dependent functionality in same function
You may also find (depending on how complex each of these tasks are) that this is a good seam for splitting out another class.
(Not sure if Swift works this way but pseudo-code:)
class YourClass {
...
4
votes
Accepted
How I can organise a project in more programming languages in Git repos?
This is very personal and depends on your style of maintaining your code and how you work with code repositories.
Then again there are recommended "best practices", that are there for a pretty good ...
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 ...
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
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
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
How to best to organize class and interface files?
As always with any design question, the first thing to do is determine who are your users. How are they going to use your organization?
Are they coders who will be using your classes? Then separating ...
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, ...
3
votes
How should I organize my source tree?
My recommendation is to download a variety of frameworks or engines and see how huge development teams handled their folders layout.
There are so many ways to organize files that it's better to ...
3
votes
Writing quality code
Each discipline, would it be accounting, archeology or brain surgery, has numerous books and numerous things to remember. Yes, you have to read a lot of books in order to acquire the minimum knowledge ...
3
votes
Using git on a project with different areas
The usage of the term "area" is a little unclear to me, but I'm understanding that you have multiple applications and webpages that share the same back-end code. If they all depend on the same back-...
3
votes
Mixing JavaScript and server-side scripting
The question here is "why" is this a bad practice.
The number one reason is the empirical observation over many years that it leads to software that is difficult to understand, maintain and change. ...
3
votes
Writing quality code
Hopefully learning is an iterative process. There are things that are not useful at the moment, but you'll remember some. Problems come up that you'll research. You will misapply them, but that's part ...
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
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
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
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
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
Should parameters of a method be in the same namespace as the class?
It's going to become hard to communicate across namespaces if you do this everywhere. If you're confident it won't cause ambiguous name conflicts you can do this:
namespace Project.Services
{
...
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