Re:On navigating a large codebase
by magicalhippo on Sunday February 14, 2021 @01:41PM
(#26134883)
You come a long way with avoiding direct calls in "if" clauses and similar, using descriptive variable names, and not trying to be clever for the sake of being clever.
For example, instead of
if (order.version > 1) ...
assign it to a descriptive variable bool orderHasChanged = (order.version > 1);
if (orderHasChanged) ...
IMO this makes it much faster to read and understand, because it says something about the intent. It can also be easier to spot bugs.It's a bit more to write, but I find it makes a big difference when coming back to the code later on, and typing is usually not the limiting factor when writing code.
Also in lots of cases you are in a hurry to meet that deadline that compromises code quality. Better to leave a comment in this case than nothing
Re:On navigating a large codebase
by disgruntledphd2 on Sunday February 14, 2021 @10:23AM
(#26133102)
Yeah, especially if you do something weird. People have often done weird strange stuff that made sense when I finally figured out the reason.
Time pressure (and particularly with contractors) can lead to some horrific long-term burdens of maintenance.
Advice that relies on people caring about their craft/having the skills to do the work well doesn't scale, so it's bad advice where those things aren't true.