Skip to main content
272 votes
Accepted

Are bad programming practices typical within the software industry?

The principles that you cited in your question are just that... principles. They are not mandates, laws or orders. While the people who came up with these principles are very smart, they are not ...
Robert Harvey's user avatar
168 votes
Accepted

If functions have to do null checks before doing the intended behaviour is this bad design?

The problem with your basic example isn't the null check, it's the silent fail. Null pointer/reference errors, more often than not, are programmer errors. Programmer errors are often best dealt with ...
whatsisname's user avatar
  • 27.6k
160 votes
Accepted

Why do many software developers violate the open/closed principle?

IMHO JacquesB's answer, though containing a lot of truth, shows a fundamental misunderstanding of the OCP. To be fair, your question already expresses this misunderstanding, too - renaming functions ...
Doc Brown's user avatar
  • 209k
154 votes
Accepted

Is it good practice to always have an autoincrement integer primary key?

It's never a bad idea to have a guaranteed unique row identifier. I guess I shouldn't say never – but let's go with the overwhelming majority of the time it's a good idea. Theoretical ...
GrandmasterB's user avatar
  • 39.4k
150 votes
Accepted

What should I consider when the DRY and KISS principles are incompatible?

KISS is subjective. DRY is easy to over apply. Both have good ideas behind them but both are easy to abuse. The key is balance. KISS is really in the eye of your team. You don't know what KISS is. ...
candied_orange's user avatar
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
  • 209k
146 votes

Is it the correct practice to keep more than 10 years old spaghetti legacy code untouched without refactoring at all in big product development?

It‘s a question of risk management: Refactoring a system always creates the risk of breaking something that worked before. The larger the system, the higher its complexity, and the higher the risk ...
Christophe's user avatar
  • 78.3k
134 votes
Accepted

Is DRY the enemy of software project management?

You seem to assume the primary objective of project management is to produce exact estimates. This is not the case. The primary objective of project management is the same as for developers: To ...
JacquesB's user avatar
  • 59.8k
125 votes
Accepted

Why are there multiple different implementations of JVM?

Why might I, as a developer be dissatisfied with the official JVM implementation that Oracle provides and decide to build up a different one? Which one? Oracle has at least three different official ...
Jörg W Mittag's user avatar
123 votes
Accepted

Is it typical for there to be no real design prior to someone being assigned a task?

If you are assigned a task that has no design done for you then doing the design is part of your task. This is not unusual. Design may have been done at some level but now the task needs it's own ...
candied_orange's user avatar
122 votes
Accepted

What's actually wrong with an endpoint returning HTML rather than JSON data?

What's actually wrong with an endpoint returning HTML rather than JSON data? Nothing, really. Each application has different requirements, and it may be that your application wasn't designed to be a ...
Machado's user avatar
  • 4,120
122 votes
Accepted

In what cases is less code not better?

A thin person isn't necessarily healthier than an overweight person. A 980 lines children story is easier to read than a 450 lines physics thesis. There are many attributes that determine the ...
M.A. Hanin's user avatar
120 votes
Accepted

Is it inadvisable to make a function that essentially renames a built-in function?

As others have already mentioned: don't create a function with a name that is similar to that of a builtin, standard-library or generally widely used function but change its behavior. It is possible ...
5gon12eder's user avatar
  • 7,206
119 votes
Accepted

Functions that simply call another function, bad design choice?

Never forget the Law of Demeter: The Law of Demeter (LoD) or principle of least knowledge is a design guideline for developing software, particularly object-oriented programs. In its general form, ...
Flater's user avatar
  • 52.1k
118 votes
Accepted

How do I know how reusable my methods should be?

It's turtles all the way down. Or abstractions in this case. Good practice coding is something that can be infinitely applied, and at some point you're abstracting for the sake of abstracting, which ...
Flater's user avatar
  • 52.1k
118 votes

Why is 2FA usually done after the correct password has been provided?

I think you're misinterpreting what actually happens. It's not doing the second factor (SMS code, authenticator app) after login is successful, but simply after one factor (password) has been verified....
Avner Shahar-Kashtan's user avatar
116 votes

Is it good practice to always have an autoincrement integer primary key?

TL;DR: Use UUID's instead of auto-increment, if you don't already have a unique way of identifying each row. I disagree with all the answers before. There are many reasons why it is a bad idea to add ...
Filip Haglund's user avatar
113 votes

Is it inadvisable to make a function that essentially renames a built-in function?

If you make a function like that where minimize(4, 10) returns 10, then I'd say that is inadvisable because your fellow programmers may strangle you. (Okay, maybe they will not literally strangle you ...
Telastyn's user avatar
  • 109k
104 votes
Accepted

Should you guard against unexpected values from external APIs?

You should never trust the inputs to your software, regardless of source. Not only validating the types is important, but also ranges of input and the business logic as well. Per a comment, this is ...
Paul's user avatar
  • 3,317
103 votes
Accepted

What is "Soft Coding", really?

The author is warning against premature abstraction. The line if (ledgerAmt > 500000) looks like the kind of business rule that you would expect to see for large complex business sytems whose ...
Ben Cottrell's user avatar
  • 11.9k
103 votes

How do unit tests facilitate design?

The great thing about unit tests is they allow you to use your code how other programmers will use your code. If your code is awkward to unit test, then it's probably going to be awkward to use. If ...
Telastyn's user avatar
  • 109k
101 votes

Is it the correct practice to keep more than 10 years old spaghetti legacy code untouched without refactoring at all in big product development?

One reason is it's really difficult to measure the loss of productivity the messy code is causing, and difficult to estimate the work it will take to clean it properly and fix any regressions. The ...
Karl Bielefeldt's user avatar
99 votes
Accepted

Should entities contain information about their amount?

This is not a question of "good practice", but a question of the requirements of the system. For example: Let's say your system is for a library. If the library has several instances of the ...
Doc Brown's user avatar
  • 209k
96 votes
Accepted

Does splitting a potentially monolithic application into several smaller ones help prevent bugs?

Yes. Generally two smaller less complex applications are much easier to maintain than a single large one. However, you get a new type of bug when the applications all work together to achieve a goal. ...
Ewan's user avatar
  • 77k
96 votes
Accepted

Multiple boolean arguments - why is it bad?

The obvious problem To resolve this however, how would one refactor this? Do you create 4 functions now? trainModelWithZerosInitOptimSGD(...) trainModelWithZerosInitOptimAdam(...) ...
Flater's user avatar
  • 52.1k
94 votes
Accepted

Is it wrong to use a boolean parameter to determine values?

API design should focus on what is most useable for a client of the API, from the calling side. For example, if this new API requires the caller to write regularly code like this if(flag) foo....
Doc Brown's user avatar
  • 209k
92 votes
Accepted

Should child nodes have a reference to their parents?

Your question is basically the same as "should linked list items have a reference to the previous item?", and the answer is the same: it depends. There are use cases when a singly-linked ...
Philip Kendall's user avatar
84 votes
Accepted

Responsibility for arrangement of elements - frontend or backend?

Any decent back-end API should receive parameters that allow some customization or filtering of the results it gives back to the client. For something that returns a list, it's usually common to ...
Bogdan's user avatar
  • 3,620
84 votes

How important is it to clearly understand requirements and architecture before starting to code?

I've seen people dive straight into the code, make bad assumptions and spend ages writing the wrong thing. On the other hand, I've seen people spend weeks "understanding requirements", ...
Philip Kendall's user avatar
82 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

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