When you have to add a new requirement to an existing code, first you should check if the code is open to the new change. Open means that the code is following the SOLID principle open for extension and closed for modification.
If the code isn’t open yet, you should first refactor it to make it open, and once done you can add the new code.
To refactor to make it open, you should be guided by the code smells.

