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

Performed refactoring the code by doing pull-down method #2451

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Sim-CAD
Copy link

@Sim-CAD Sim-CAD commented Mar 25, 2022

The "relax method" of the parent class is unnecessarily inherited by both child classes. To avoid an undesired duplication of a method in the child class where it is not used at all, I transferred the "relax method" to the child class (BellmanFordShortestPathAlgorithm) and removed it from the parent class (DijkstraShortestPathAlgorithm)

This function has 3 problems:
1) It is a complex method where Cyclomatic complexity is 29, 2) There are duplicate blocks of code and 3) It is a long method with lines of code equals to 110.
Two new methods are created after this refactorization process which is collectColorSamples and getClosestColorSamples.
…ngNodeSizeTransformer and RankingLabelSizeTransformer extended class RankingSizeTransformer. In both child classes, they are implementing the same isNode method with the same implementation. As it is promoting duplicate code, it is always better to put the duplicate code in the parent class so that all other classes that uses this parent class can utilize this method without re-writing it.
…face is bulky (a large number of public methods). The goal of extracting XML methods from this class was not only to solve the above smell, but also to ensure that this class adhered to the "single responsibility concept."
…ild classes. I pushed down the relax method to the child class (BellmanFordShortestPathAlgorithm) and removed it from the parent class to avoid an unwanted duplication of a method in the child class where it is not utilised at all (DijkstraShortestPathAlgorithm)
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

Successfully merging this pull request may close these issues.

None yet

1 participant