It’s tempting: You need to solve a problem and you know that in 6 months time you will need to support a related feature. Instead of just solving your current problem, you now start to think ahead, realizing it will create more work once your team starts working on this new feature. You start to see ways that you could prevent some of this refactoring work, perhaps by introducing some extension points, maybe an interface or an abstract class is needed and then the code will be beautiful, well organized and you have done your professional duty.
Wrong!
What you have actually done is:
- Introduced more code as needed to solve the current problem.
- Introduced complex abstractions, increasing complexity of the code base.
- Code that requires review and perhaps additional unit- and end-to-end tests
- Code that makes it harder to read and understand the code of the current feature.
- Written code that is very likely to never be needed or will likely anyway need to be rewritten when the actual requirements of this future feature are known.
- Increased time-to-market by not focusing on what is needed here and now.
- Created more work for everybody involved: More discussions, more testing, more documentation.
While this may seem a bit over-dramatic – you just wanted to be a bit proactive for this one particular upcoming feature – the problem is that once you go down this road, this way of thinking starts to creep into every feature being developed and the end-result is a 10x more complicated code-base than needed to solve the actual here-and-now business requirements.
As developers we often do this out of the best intention, we do it because we care. We tend to think that a code-base that is not well prepared for future requirements is full of technical debt. We will blame business management that not enough time is reserved for managing this technical debt – when in reality we mean doing unnecessary complex refactorings that prepares for vague future requirements.
We also do this because we are seniors, because we have confirmation-bias based on past experiences – we tend to remember the times where upfront code preparation was well invested, but forget about all the other times where it was simply a waste of time.