Refactoring : Extract method getBackboneAtomArray changes to reduce the cyclomatic complexity#1058
Merged
Merged
Refactoring : Extract method getBackboneAtomArray changes to reduce the cyclomatic complexity#1058
Conversation
added 3 commits
April 4, 2023 21:38
…ity of getBackboneAtomArray
…rlapScore method to eliminate complex conditional smell
…te complex conditional smell
josemduarte
requested changes
Apr 6, 2023
josemduarte
left a comment
Contributor
There was a problem hiding this comment.
Thanks! nice improvements. See one comment below.
|
|
||
| List<Atom> atoms = new ArrayList<>(); | ||
| Set<String> nucleotideAtomNames = new HashSet<>(Arrays.asList(C1_ATOM_NAME, C2_ATOM_NAME, C3_ATOM_NAME, C4_ATOM_NAME, O2_ATOM_NAME, O3_ATOM_NAME, O4_ATOM_NAME, O5_ATOM_NAME, OP1_ATOM_NAME, OP2_ATOM_NAME, P_ATOM_NAME)); | ||
| Set<String> aminoAcidAtomNames = new HashSet<>(Arrays.asList(CA_ATOM_NAME, C_ATOM_NAME, N_ATOM_NAME, O_ATOM_NAME)); |
Contributor
There was a problem hiding this comment.
I'd propose to extract these 2 as constants on top of this class with names NUCLEOTIDE_BACKBONE_ATOMS and AMINOACID_BACKBONE_ATOMS
…nd AMINOACID_BACKBONE_ATOMS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The method getBackboneAtomArray had a cyclomatic complexity of 22, hence refactored the method was to optimize the code.
This refactoring can be qualified as extract method refactoring.
The logic and the output after refactoring remain the same.