OSSpk / Library-Management-System-JAVA

📚 A sophisticated Library Management System designed in Java while following the concepts of decoupled layers (entities) and minimal code in interface (GUI).
https://github.com/harismuneer
MIT License
345 stars 228 forks source link

Suggestion of refactorizing code #7

Open AIToala opened 3 years ago

AIToala commented 3 years ago

Suggestion

Hi I'm currently looking up your code because i was interested in this project and i found some spaces of code that can be refactored. This are suggestions so please don't bear any mind if I commit errors. I'll appreciate any comments about it. 👍🏽 For finding any of these smell codes i used as reference this webpage: https://sourcemaking.com/refactoring

Code Smells

Shotgun Surgery

So i found that in some classes you use the object or instance variable of HoldRequest. And HoldRequest as well uses some classes for Constructor purpose. Because there exists this bidirectional relationship, in the future or next updates can provoke to look up and create changes in multiple classes. So as a refactor i propose that you create a new class called HoldRequestManager so that in here you manage any interaction with the Object HoldRequest. (Refactors

used Move Method and Move Field image image

Duplicate Code

Similar to the previous refactor there's duplicate code in all the classes that uses HoldRequest as a instance variable so it would be better to create an interface that contains all the methods used on this classes.

used Extract Interface image

Inappropiate Intimacy

This refactor is to get rid of the bidirectional relationships so you keep a more organized code and provokes optimization when you need mantainance or support on your code.

used Change Bidirectional Association to Unidirectional image

Regards

Thanks for paying attention. This is part of an assignment so if I'm wrong please comment. I'm glad to recieve constructive opinions about anything. Happy Coding and keep up the great work!

harismuneer commented 3 years ago

@AIToala thanks for your interest to refactor the code! Can you also generate PRs for the relevant improvements that you do. I would be very happy to merge your improvements :)