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.
For example, instead of
assign it to a descriptive variable 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.