This document is an attempt to get the team on the same page about the refactoring process we want to adopt.
-
Defined a goal to reach.
- Make the code easier to deal with.
- Ease the addition (or update) of features.
-
Remove technical limitation
-
Maintainability: Clean code / SOLID philosophy
-
Make it easier to understand
- Defined how we can reach that goal.
- Which techniques?
- More domain-oriented and less "algorithmic".
order.IsUncrossed()
instead oforder.offet < -1
- avoid graph style code, more like tree structure.
- SOLID
- clean code
- avoid coupling: Better interfaces, or event driven packages.
- More domain-oriented and less "algorithmic".
- Which techniques?
- Defined critical code path for maximum impact.
- Identify the hottest path of code change :
- compare results with cyclomatic complexity (
gocyclo
). - rate of changes of the code and files
- number of import inside a file -> reveal a code smell ?
- compare results with cyclomatic complexity (
- Identify the hottest path of code change :
- Defined medium to share the knowledge.
- Create workshops on specific problems to find a solution, and be on the same page.
- Save our decisions into a file.
- Use external articles on the matter. file with "do this" and "don't do this".
Be discussed before being addressed.
Verify the test coverage (coverage is not everything) before refactor.
Beware of refactoring scope to not go too far, and cause conflict.
It's done along the way.
Refactor just before we add a feature to a code base, to ease its addition.
Questions:
- What kind of code makes feature harder to add?
Refactor to make the code more understandable.
Questions:
- What's a code that is easier to understand?
Basically, the boy scout's rule.
Always leave the camp site cleaner than when you found it.
Questions:
- How to avoid overlapping with someone else?
- Into the same PR as the one of the feature or a different one?
- find a tool to highlight hot code path
- Bootstrap files for coding style, convention and stuff.
- Find the biggest offenders and start from there to build our guideline.
golangci
: Use linters to get more insight on smells.