352
votes
Accepted
Why do we need so many classes in design patterns?
This is an optimization problem
A good engineer understands that an optimization problem is meaningless without a target. You can't just optimize, you have to optimize for something. For example, ...
225
votes
Accepted
Should I refactor the code that is marked as "don't change"?
It seems you are refactoring "just in case", without knowing exactly which parts of the codebase in detail will be changed when the new feature development will take place. Otherwise, you would know ...
149
votes
Accepted
Why are some C programs written in one huge source file?
Using multiple files always requires additional administrative overhead. One has to setup a build script and/or makefile with separated compiling and linking stages, make sure the dependencies between ...
140
votes
Should I refactor the code that is marked as "don't change"?
Yes, you should refactor the code before you add the other features.
The trouble with comments like these is that they depend on particular circumstances of the environment in which the code base is ...
83
votes
Why are some C programs written in one huge source file?
Because C isn't good at modularization. It gets messy (header files and #includes, extern functions, link-time errors, etc) and the more modules you bring in, the trickier it gets.
More modern ...
71
votes
What are the benefits of multi-file programming?
There are a lot of technical reasons behind using multiple files when writing large complex systems. All of them are meaningless in the face of the best reason to use multiple files:
Readability.
...
70
votes
Why do we need so many classes in design patterns?
Well, first of all, readability and maintability are often in the eye of the beholder.
What is readable to you may not be to your neighbour.
Maintainability often boils down to discoverability (how ...
60
votes
Should I refactor the code that is marked as "don't change"?
My question is: should I refactor the code when I encounter such warnings from the authors
No, or at least not yet. You imply that the level of automated testing is very low. You need tests before ...
32
votes
Why do we need so many classes in design patterns?
Please explain me, why do we need this DDD style, lots of Patterns?
First, a note: the important part of DDD is not the patterns, but the alignment of the development effort with the business. Greg ...
30
votes
Why do we need so many classes in design patterns?
There are many good points in the other answers, but I think they miss or don't emphasize an important conceptual mistake you make:
You are comparing the effort to understand the complete program.
...
28
votes
What are the benefits of multi-file programming?
The question falls into same category as why buildings are not build from one piece of rock but a bunch of bricks?
Answer:
easier to navigate than scroll through one huge file
make recompile works ...
24
votes
Should I refactor the code that is marked as "don't change"?
Remember the G. K. Chesterton's fence: do not take down a fence obstructing a road until you understand why it was built.
You can find the author(s) of the code and the comments in question, and ...
22
votes
Accepted
How to deal with large source codes?
For example, a simple "if" can occupy a whole screen (more or less 30 to 40 lines). I do not need to mess with it anymore, but it's not a function, it's not a class, just a part of the code that has ...
21
votes
What are the benefits of multi-file programming?
The other answers are fine, but something they're missing is actual technical limitations.
For example, you can't actually save all of the code for my day-job application in one file - it's bigger ...
20
votes
Why do we need so many classes in design patterns?
Because testing code is harder than writing code
A lot of answers have given good reasoning from a developer's perspective - that maintenance can be reduced, at the cost of making the code more ...
18
votes
Why do we need so many classes in design patterns?
Please explain me, why do we need this DDD style, lots of Patterns?
Many (most...) of us really don't need them. Theoreticians and very advanced, experienced programmers write books about theories ...
16
votes
Why are some C programs written in one huge source file?
In addition to the simplicity factor the other respondent mentioned, many C programs are written by one individual.
When you have a team of individuals, it becomes desirable to split the application ...
16
votes
Terminology - is source code a program?
See the Wikipedia entry for Program: (I've added the bold)
A computer program is a collection of instructions that performs a specific task when executed by a computer. A computer requires programs ...
15
votes
Accepted
Where to archive code
If it's for a program which is already under source control, just keep these changes in a branch of that repo.
For odd bits of code, you could use almost anything, but some good options would be ...
15
votes
Did Dijkstra intend for code modularization, when he wrote about separation of concerns?
Separation of concerns is an abstract way of thinking that consist in considering separately things that do not have to be related.
Modularisation (separating unrelated group of functions into ...
12
votes
Accepted
What is the difference between predicate and branch
A predicate returns a yes/no answer to a question - that is, a boolean conditional.
A branch is what you do depending on the answer (assuming you do different things).
So, in c type pseudo code:
if(...
11
votes
Accepted
What is the difference between Code Smells and Anti Patterns?
A Code Smell is something which should be investigated. Is it a piece of delicious cheese or is it rotten beef? An Anti-Pattern is just bad, a Code Smell is something which may or may not be bad.
...
11
votes
Did Dijkstra intend for code modularization, when he wrote about separation of concerns?
I would suggest that, whilst the paper is of historic interest, what Dijkstra meant by the term "separation of concerns" over 40 years ago is not particularly relevant today. Nowadays it is used ...
11
votes
What are the benefits of multi-file programming?
I have been told to write large applications in several different files. They say it will run faster. What makes it run faster?
Also does a multifile application ACTUALLY run faster than a singlefile ...
10
votes
If taking over code of a third party, what are the delivarables?
You're being offered a release with source. What you're asking for is the source code repository.
No modern developer would want to be without the history in the repository.
The question is, what ...
10
votes
Accepted
GitHub - Should I unassign an issue once closed?
In general you don't want to unassign an issue if it's closed.
There are two reasons why you don't want to do it:
If an issue is reopened then you want the original people to be involved
You want ...
10
votes
Check if variable is not null before setting to null
If _someVar is a property instead of a variable,
and setting it has side-effects, that might be functionally different code.
and setting it is considerably more involved than reading it, testing, and ...
9
votes
Is there evidence that programming will die/not-die because of LowCode/NoCode?
Forty years ago a piece of "no code" software was released called "The Last One", with the idea that it would be the last program that needed to be written.
This turned out not to ...
9
votes
Fighting the half-life of code
Disclaimer: I am a guy who leads a team which maintains > 100 programs, where most of them have a long history, several of them much longer than just 10 years. From that experience, I can tell you ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
source-code × 275open-source × 21
code-quality × 19
version-control × 18
licensing × 14
coding-style × 12
documentation × 12
java × 11
code-reviews × 11
programming-practices × 10
maintenance × 10
comments × 10
compiler × 8
design × 7
javascript × 7
git × 7
project-management × 7
development-process × 7
coding-standards × 7
gpl × 7
legal × 7
c++ × 6
c × 6
security × 6
interview × 6