344 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, ...
user avatar
  • 24.7k
224 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 ...
user avatar
  • 185k
146 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 ...
user avatar
  • 185k
141 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 ...
user avatar
84 votes

Bad sign if nobody can comprehend one's code?

There are several questions that you raise. 1) Is this a clear sign that the coder is not cut out for professional programming? No. Developers often go through stages where they learn about an idea ...
user avatar
  • 3,055
81 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 ...
user avatar
70 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. ...
user avatar
69 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 ...
user avatar
  • 11.5k
60 votes
Accepted

Why aren't there code overviews for open-source projects?

Because it's extra effort to create and maintain such a document, and too many people don't understand the associated benefits. Many programmers aren't good technical writers (although many are); ...
user avatar
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 ...
user avatar
  • 8,027
51 votes

Why did BASIC use line numbers?

On early microcomputers editing was line based. You couldn't just move freely around in the source code and edit. You had a single line at the bottom of the screen where you could type commands and ...
user avatar
  • 54.7k
46 votes

Why did BASIC use line numbers?

If you are thinking of BASIC dialects of the 8-bit home microcomputers of 80's, then those computers did not have text editors (unless you bought some word processor application). There was no way to ...
user avatar
  • 3,694
38 votes

Bad sign if nobody can comprehend one's code?

The second code does not return 42 or 7. for b = 1: (1 * 42) | (~(1 - 1) * 7) 42 | (~(0) * 7) 42 | (-1 * 7) 42 | -7 -5 for b = 0: (0 * 42) | (~(0 - 1) * 7) 0 | (~(-1) * 7) 0 | (0 *...
user avatar
35 votes

How safe is it to compile a piece of source code from a random stranger?

It depends. This piece of makefile could delete your home directory : all: rm -rf ~ So, if you need to use a tool (like cmake or makefile system), then it is not safe. It just depends how ...
user avatar
  • 13.9k
34 votes

When does one hard-code actual data values into the code as opposed to using a DB?

I don't think these two statements really represent a consensus about when to hard code data: If it is a single variable or a simple structure, or an array of a few values, put data right in the code ...
user avatar
  • 1,058
31 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 ...
user avatar
29 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. ...
user avatar
27 votes
Accepted

How to do documentation for code and why is software (often) poorly documented?

How to document code? You already have a hint: look at how Java API is documented. More generally, there is no unique set of rules which apply to every project. When I work on business-critical ...
user avatar
27 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 ...
user avatar
23 votes
Accepted

Is reading javadoc preferable to reading source code to familiarise yourself with a library?

The recommendation is probably about programming to an interface rather than the implementation. Sure, if you have access to the code then there's nothing stopping you from looking at the ...
user avatar
  • 11.5k
23 votes

How safe is it to compile a piece of source code from a random stranger?

I am pretty sure somewhere in the business there are some clever guys who have already created such a hack for a specific language and compiler version. My favorite place to look for something like ...
user avatar
  • 185k
23 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 ...
user avatar
  • 23.9k
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 ...
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 ...
user avatar
  • 107k
19 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 ...
user avatar
  • 337
18 votes
Accepted

Apollo-11: Using inclusion instead of a linker

They seem to mean simple textual concatenation / insertion. In other words, even though the source text was split into individual files, the program wasn't split into modules.
user avatar
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 ...
user avatar
  • 3,164

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