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

Refactor: Improve Readability and Maintainability with Explaining Variables, Renaming, and Polymorphism #362

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

Conversation

Saikat-Raj
Copy link

@Saikat-Raj Saikat-Raj commented Nov 27, 2024

This pull request introduces several refactorings to enhance code readability, reduce duplication, and improve maintainability. The following changes have been made:

Introducing Explaining Variable (useHttpProtocol):
A new variable is introduced to replace an ambiguous conditional check, improving the clarity of the condition and making the code more self-explanatory.

Renaming credentials() to getCredentials():
The credentials() function has been renamed to getCredentials() to better reflect its purpose, enhancing the readability of the code.

Applying Polymorphism in DFSPrivateKeyServiceImpl:
A KeyType hierarchy has been introduced to abstract key types and their corresponding prefixes.
Conditional logic in the getKeyByPrefix method has been replaced with polymorphism, simplifying the code and improving maintainability.

Moving getStorageAccessCredentials to a Dedicated Helper Method:
The logic for retrieving storage access credentials has been encapsulated into a dedicated helper method, improving code clarity and separation of concerns.

Extracting CacheCreator Class for Cache Logic:
The cache creation logic has been extracted into a new CacheCreator class, organizing the code better by separating the cache handling responsibilities.

Extracting createCache Method to Avoid Duplication:
A new utility method, createCache, has been introduced to eliminate the duplication in cache creation logic. This improves maintainability and readability.

…readability

Replaced ambiguous conditional check with an explaining variable 'useHttpProtocol'. This improves code clarity by making the condition more self-explanatory, enhancing overall readability.
Renamed the 'credentials()' function to 'getCredentials()' to better reflect its purpose of retrieving credentials. This enhances code readability and makes the function's intent clearer.
…trieval

- Introduced a 'KeyType' hierarchy to abstract key types and their corresponding prefixes.
- Replaced conditional logic in 'getKeyByPrefix' with polymorphic dispatch.
- Enhanced code readability and maintainability by reducing complexity.
Copy link

sonarcloud bot commented Nov 27, 2024

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.

1 participant