Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requirement of Refactoring in the code #1 #9

Open
guryashdhall opened this issue Mar 19, 2022 · 0 comments
Open

Requirement of Refactoring in the code #1 #9

guryashdhall opened this issue Mar 19, 2022 · 0 comments

Comments

@guryashdhall
Copy link
Contributor

guryashdhall commented Mar 19, 2022

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.

image
image

2) RENAME METHOD/VARIABLE

Class: Borrower.java

image
Class: Person.java
image

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.

image

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.

image

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

This was referenced Mar 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant