Skip to content

Requirement of Refactoring in the code #1 #9

Open
@guryashdhall

Description

@guryashdhall

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions