Refactoring: Improving the Design of Existing Code
Author: Martin Fowler Publishing/Release Date: December 17, 2018 Link: https://www.amazon.com.au/Refactoring-Martin-Fowler/dp/0134757599/ref=pd_lpo_14_t_2/357-3735444-7277655?_encoding=UTF8&pd_rd_i=0134757599&pd_rd_r=6a08fc0f-7284-45df-b7cc-886abfcb19ae&pd_rd_w=GsUNw&pd_rd_wg=jWVIy&pf_rd_p=ad2d1e6e-bc60-4795-b4c0-2dbd35f6678d&pf_rd_r=9KSZG9G6MP70986EFPZP&psc=1&refRID=9KSZG9G6MP70986EFPZP
If the code works and doesn’t ever need to change, it’s perfectly fine to leave it alone. It would be nice to improve it, but unless someone needs to understand it, it isn’t causing any real harm. Yet as soon as someone does need to understand how that code works, and struggles to follow it, then you have to do something about it.
- Extract function
- Rename variables/function arguments
- Replace temporary (local) variables with queries