Eliminating Code Smells
Principal Software Tester
To eliminate a code smell, you first need to identify that there is a smell, then you need to come up with a way to safely remove that smell. However, removing code smells can have many advantages, such as making your code base cleaner and thus easier to read and maintain.
Identify code smells
Have a look at the provided code examples (or pick some code that you or your team has created) and identify anything that you think is a code smell. Also think about why your finding is a code smell.
Eliminate code smells
Eliminate the found code smells by applying proper programming principles, maybe by introducing meaningful names for variables or removing duplication.
Also think about:
Advantages & disadvantages of your solution
How to ensure you didn’t introduce any bugs or other code smells?
Removing code smells is a good way to improve the code base in many ways. It speeds up development, decreases the risk of bugs & failures as well as technical debt. Also, it makes it easier to maintain the application in the future, by any programmer, including yourself.
What you’ll learn
- Follow good programming techniques & implement good design
- Decrease the risk of future bugs & failures
- Reduce the risk of technical debt
Example code that can be used in this activity can be found at https://christianbaumann.dev/workshops/2022-testbashuk-workshop-codesmells-101/
Test Automation Code Smells - Angie Jones - https://bit.ly/mot-acs
Your Code Can Smell! How to Fix It - https://bit.ly/mot-csf
Swich Statement code smell - https://bit.ly/mot-scs
Code Smell 10 - Too Many Arguments - https://bit.ly/mot-cs10
Refactoring: This class is too large - https://bit.ly/mot-ctl