4 ms·
One of the great challenges in coding is fixing somebody else's code with 100% confidence you didn't break something bigger. Each function may appear to have a
by zug_zug 5y ago
One of the great challenges in coding is fixing somebody else's code with 100% confidence you didn't break something bigger.
Each function may appear to have a contract, but it's sometimes unclear if other code is relying on the apparent (mis) behavior of the code. Obviously any sort of global state (including config files, database), magic, parallelism, async, abstraction layers make this exponentially more complex.
The author knows all the things that aren't there, it's easy. The bug-fixer just has to check every single thing or risk being bitten by something spooky (e.g. a database trigger).
- whydid 5y agoTests and compiled languages help reduce risks associated with fixing a bug in a function. The classic fear that "I don't know what else uses this function" is simple enough to solve for a developer who knows how to perform static analysis. However, many don't. Even if they do know how to find all areas where a function is being called, it's easier for the "busy" developer to make a copy of the entire function and just change the part they need.
- heisenbit 5y agoStatic analysis of use requires knowing all the calling parties and having access to their code. A lot of systems these days are not static monoliths but dynamic assemblies.
- cratermoon 5y agoOr the code you're working on is part of a library or some other component that's used by other projects, some of which you don't even know about.
- cratermoon 5y ago> One of the great challenges in coding is fixing somebody else's code with 100% confidence you didn't break something bigger. That's the entire premise of the techniques in Working Effectively With Legacy Code: how to ensure the code you write changes the behavior that you want to change but doesn't change behavior that shouldn't. Great book.