Skip to main content
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, ...
John Wu's user avatar
  • 26.9k
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 ...
Doc Brown's user avatar
  • 214k
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 ...
Doc Brown's user avatar
  • 214k
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 ...
Kilian Foth's user avatar
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 ...
Mason Wheeler's user avatar
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. ...
candied_orange's user avatar
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 ...
MetaFight's user avatar
  • 11.6k
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 ...
Daenyth's user avatar
  • 8,147
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 ...
VoiceOfUnreason's user avatar
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. ...
Jens Schauder's user avatar
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 ...
Polar Bear's user avatar
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 ...
9000's user avatar
  • 24.3k
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 ...
candied_orange's user avatar
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 ...
Telastyn's user avatar
  • 110k
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 ...
Bilkokuya's user avatar
  • 347
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 ...
Vector's user avatar
  • 3,231
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 ...
Ron Ruble's user avatar
  • 294
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 ...
Dan Pichelman's user avatar
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 ...
Dan1701's user avatar
  • 3,108
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 ...
Christophe's user avatar
  • 80.6k
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(...
Oded's user avatar
  • 53.7k
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. ...
Jörg W Mittag's user avatar
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 ...
David Arno's user avatar
  • 39.5k
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 ...
pjc50's user avatar
  • 14.8k
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 ...
candied_orange's user avatar
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 ...
Batavia's user avatar
  • 460
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 ...
Deduplicator's user avatar
  • 9,131
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 ...
pjc50's user avatar
  • 14.8k
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 ...
Doc Brown's user avatar
  • 214k

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