4 ms·
Refactoring has a fixed cost, not refactoring has an ever increasing cost. Clearly either way you will pay but if you refactor you will end up paying much less
by jacquesm 3y ago
Refactoring has a fixed cost, not refactoring has an ever increasing cost. Clearly either way you will pay but if you refactor you will end up paying much less in total. The bigger problem is not the cost per-se but the resource allocation issue associated with refactoring: you can go bankrupt with very clean refactored code that gives your competition time enough to bury you with a crappy codebase and the features that the customer needs.
All of these are balancing acts. It's never 'refactor or not', it's how much to refactor and what to let go? These are strategic issues and they go hand-in-hand with business goals and knowledge about the longer term roadmap. For instance it would be pointless to refactor a codebase that will end up being supplanted by another product or for which a strategic acquisition is planned of a company with a technically superior product.
- lionkor 3y agoIt's also sometimes "when to refactor", because eventually you either have to refactor or rewrite (or retire).
- jacquesm 3y agoYes, correct, sometimes you will have to do it anyway but simply not now because there are more pressing needs. This more often than not leads to runaway technical debt though, and sooner or later the problem becomes insurmountable. I've found over the years that refactoring is best done as a continuous background task with a certain percentage of capacity allocated to dealing with it and addressing the parts that you most want to avoid first.
- sokoloff 3y ago> Refactoring has a fixed cost, not refactoring has an ever increasing cost. That means that refactoring has an increasing cost as well (with increased frequency, the total money spent on refactoring increases).
- jacquesm 3y agoNo it doesn't because you only write so much code.
- sokoloff 3y agoI think you’re then arguing that refactoring doesn’t have a fixed cost per occurrence, but rather that the more code you write between refactorings, the cost of the refactoring increases (which I agree with).
- seadan83 3y agoIf time is cost, then yes, everything has an increasing total cost. The question is more about complexity and interactions. Does a specific subsystem interact with N modules, or with 1. If N+1 module interacts with N, then the cost of maintaining that system will explode very quickly. OTOH, if the system is revisited after that test goes green to increase modularity, reduce dependencies, then complexity is now potentially growing sub-linearly to the number of modules rather than O(n!)