Examine the following code: https://github.com/ShmilyJxu/Shared/tree/main/SRP-Code/src. One implication of SRP is that there should only be one reason
Fantastic news! We've Found the answer you've been seeking!
Question:
Examine the following code: https://github.com/ShmilyJxu/Shared/tree/main/SRP-Code/src.
One implication of SRP is that there should only be one reason to change a class. If you have more than one reason, then the class should be refactored into multiple classes.
Give the above code, what are the problems regarding SRP? What will happen if we must change the way a bill is calculated? What about if we want to generate a new type of report?
Finally, consider what will happen if we have not clearly defined the responsibility of a class.
Do the following:
- Identify the pieces of the class that need to be changed to meet SRP.
- Refactor the code creating two new classes (calculate bills, write report), each with a single responsibility and then modify main() to implement the new classes. Test that your code produces the same results as the initial code. Provide your refactored code for the answer to Q1.
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date: