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 of generatePalette function by doing extracting method. #2448

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

Conversation

Sim-CAD
Copy link

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

generatePalette 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.

After refactoring the cyclomatic complexity got reduced to 16.

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.
@Sim-CAD
Copy link
Author

Sim-CAD commented Mar 25, 2022

Hi

FYI, I am currently working on the refactoring of codes and my university work.

Thanks
Smriti

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