You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Initially the method updateBorrowerInfo() had three functionalities of updating the name, address and phone number. These functionalities are separated by creating individual methods for each functionality updateBorrowerName() , updateBorrowerAddress() and updateBorrowerPhoneNumber().
This not only makes the code more readable and understandable but can also be used in extending the functionality of the Library management system by providing only the option of changing the name to admin and giving just the access of changing address and phone numbers to individual borrowers.
2) RENAME METHOD/VARIABLE
Class: Borrower.java
Class: Person.java
3) Move Method
Add Librarian function should be there in Librarian class instead of Library as it is better suited to be the component of that class.
4) Extract Class
Class: Book.java
Hold Requests operations are performed inside the book class. And this violated the principle of single responsibility, so the responsibility is split by creating a new class HoldRequestOperations.
5)Changing Bidirectional Association to Unidirectional
Object or instance variable of HoldRequest is used in various classes. Because of this, there is a bidirectional relationship between Hold Request and Book class. Using HoldRequestOperations class changes the bidirectional relationship to unidirectional. In the future, for any additional features/modifications, users will not need to look up and make changes to several classes.
Thanks for giving me the opportunity to refactor your code! Please let me know your suggestion/feedback for the same
The text was updated successfully, but these errors were encountered:
Refactoring Required
1) Extract Method
Class to be updated: Borrower.java
Initially the method updateBorrowerInfo() had three functionalities of updating the name, address and phone number. These functionalities are separated by creating individual methods for each functionality updateBorrowerName() , updateBorrowerAddress() and updateBorrowerPhoneNumber().
This not only makes the code more readable and understandable but can also be used in extending the functionality of the Library management system by providing only the option of changing the name to admin and giving just the access of changing address and phone numbers to individual borrowers.
2) RENAME METHOD/VARIABLE
Class: Borrower.java
Class: Person.java
3) Move Method
Add Librarian function should be there in Librarian class instead of Library as it is better suited to be the component of that class.
4) Extract Class
Class: Book.java
Hold Requests operations are performed inside the book class. And this violated the principle of single responsibility, so the responsibility is split by creating a new class HoldRequestOperations.
5)Changing Bidirectional Association to Unidirectional
Object or instance variable of HoldRequest is used in various classes. Because of this, there is a bidirectional relationship between Hold Request and Book class. Using HoldRequestOperations class changes the bidirectional relationship to unidirectional. In the future, for any additional features/modifications, users will not need to look up and make changes to several classes.
Thanks for giving me the opportunity to refactor your code! Please let me know your suggestion/feedback for the same
The text was updated successfully, but these errors were encountered: