I prefer known "bad" code than assumed-perfect new code for knowability reasons (Six Sigma) - You can control, fix and support known(bad, but consistent) processes far easier - And the typical way forward is to bring consistency first.
An example (One that I've trapped myself with in the past):
1. I write one half-good piece of code.
2. I copypasta that in 5 other places (Defect: Now was the time to refactor. Perhaps understandable when you have a large code base).
3. Someone else adds a 2nd similar-but-better piece of code.
4. Someone else adds a 3rd similar-but-even-better piece of code.
5. We have 3x different similar pieces of code that should be consolidated into a single abstract helper method.
6. Perfect code #2 has a bugfix applied because it turned out that we forgot about an old edge case that method #1 covers.
7. Perfect code #3 has a cool enhancement, and diverges it's purpose away from the other two methods.
The two issues with this design pattern are:
1. The refactor becomes harder. The difference necessarily causes difference. Consistency keeps stuff glued together, makes for easier refactors, and therefore more likely to be done.
2. Multiple ways of doing the same thing, with different performance characteristics (two methods having unknown performance characteristics). The old code might be "bad", but it's also probably less buggy and a more known quantity.
This is another case of Perfect being the enemy of Good.
No comments:
Post a Comment