Release early, release often - just don't forget to refactor ;)
As software engineers, our main objective is to deliver. Once our code works as expected, we commit it and then run it in the CI/CD pipeline.
While seemingly straightforward, it’s not as simple as it may seem. There exists a constant tension in the programming world that stems from shipping fast or slow at the cost of software maintainability aka technical debt.
Technical debt is opting for the easy solution now instead of using a better approach that would take longer. More often than not, many agile teams choose the former than the later.
Deliver now and fix it later is a very popular approach because teams are able to reduce the time it takes to get product-to-market. It’s also great because software engineers don’t have to spend too much time developing something that might be used. For many companies, it’s a fair trade off. Nevertheless, in order to make this approach work, continuous refactoring must be done — else technical debt will accumulate.
“Fixing it later” is synonymous with code refactoring.
Code refactoring is the process of clarifying and simplifying the design of existing code, without changing its behavior.
From the business and end user perspective, this doesn’t affect them because the product doesn’t change. However, from the developers’ perspective, refactoring reduces technical debt and increases software stability.
This makes a huge difference in larger projects.
The following is a general list of things to look for when identifying code that could use some refactoring:
- Copy & paste (duplicate) code
- Ambiguous variable names
- Unused variables / methods / classes
- Suboptimal performance
- Your method’s code is longer than your screen
- Violation of DRY, KISS, YAGNI, SOLID and other software engineering principles
Feel free to suggest any other scenarios in the comments.
- Results: both example produces the same outcome, which is to unset the users rank.
- Visually: Pre-refactoring has a lot more code than post-refactoring.
- Performance: Pre-refactoring makes up to 10000 roundtrips to the database, while post-refactoring makes 1 roundtrip to the database.
Imagine if more developers joined this project and stumbled upon this code. Do you think it would be easier for them to understand and contribute to pre or post refactoring?
Just as the author would improve their writing to make it easier for the readers to understand, developers should also improve their code to make it easier for other developers to understand.
My advice to those in a team where you’re constantly cranking out new features, consider setting aside a sprint or two for stability. Write some unit tests to increase your code coverage and refactor some code to make your apps more robust. I know it might seem like it’ll slow down development time, but it’ll actually increase your team’s efficiency and output in the long run.
Thanks for reading! Originally posted on Santora Nakama.