In my software construction, design, and architecture class we’ve focused a lot on (believe it or not), the design and structure of software. Software is typically quite intricate and designing it as efficiently and cleanly as possible is almost never accomplished the first time it is coded. “Code Refactoring and why you should refactor your code” by Lazar Nikolov is a great blog dedicated at explaining what refactoring is, why you should use it, and when you should use it.
Refactoring is just the process of identifying technical debt and code smells withing the existing program and modifying the code to be more optimized removing these issues without changing the user interface behavior. As Nikolov describes there are many objectives of refactoring such as increasing readability, maintainability, reusability, optimizing the performance, and enforcing code standards. There are many situations you should consider refactoring in. Such as DRY where you find and replace repetitive information with an abstraction that is less likely to change, or when working with someone else’s “bad” coding that you need to build on.
The key takeaway here is that no programmer does the job perfectly the first time. Programs constantly evolve and have changing specifications that must be met. A good programmer is one who can roll with those punches and change the code as needed. Our most recent homework assignment really focused in on this and had us refactor the code we we’re working with three different times each time using a different architecture. In doing so we learned each time how the previous code could be improves upon to function better and with less bugs even though the original code worked fine. Moving from the strategy pattern to the singleton pattern lastly to the simple factory pattern allowed us to see how each new version after refactoring solved a different problem from the previous. Even though they all worked fine we could see the optimization occurring.
Refactoring is certainly a concept I plan on carrying with me into the future. I’m not sure if there’s a good programmer out there that doesn’t use this concept constantly. Having the ability to constantly adapt my code to best suit it to not only its current task but any future ones that may arise is an incredibly good skill to have. I know it will help me not just as a student at Worcester State but as a professional software developer someday too.
From the blog CS@Worcester – DPCS Blog by Daniel Parker and used with permission of the author. All other rights reserved by the author.
