Excel driven refactoring ! My first ever ;)
One of the oldest saga of Network UI was needing a huge refactor. Well... not a refactor, the goal was to remove it completely.
I made it before I built my best practices with Saga. And this method was one that help me understand... not to do like this ;) This method was called on various users and automatic actions to update various elements of the UIs:
- Timeline
- Map
- Grid
- Stats
- Nodes names
- ...
While it was updating everything, it was quite simple. But for performance improvements, and to limit the queries on the servers, many parameters were added to limit some refresh to some situations.
However, this is not the right pattern. It is better to have each component have its own saga watching the actions they would need to refresh on. This is the pattern I implemented almost everywhere else, and it scales good, while limiting the responsibility in one place.
To perform this refactor was risky. As the function was called from many places with various arguments.
So I used ... Excel ! ;)
1. List the calls
2. List the behaviors from the params
3. List the needs for each call
4. Find the actions behind each need, and subscribe the update sagas to those actions
5. Tests!!
All in all... 5h of preparation, 5h of refactor + fix and... it rocks :) !
So much more understandable and maintenance easy. What a relief to remove this old code.
Code are aging badly. Really ;)