Codebase Refactoring for Improved Readability and Maintainability #861
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.
This pull request introduces a series of six refactoring changes aimed at enhancing the readability, maintainability, and overall design of the codebase. Each refactoring is summarized below:
Introduce Explaining Variables
Refactored the equalTimeValue method within the Equality class by adding two explaining variables: equalTimeStamp and equalTolerance.
Extract Method
Simplified the getJsonDatatypeFromDatatypeIri method in the DataTypeIdImpl class by extracting logic for the default case to a new method, enhancing readability.
Decompose Conditional - WbEditingAction
Improved the performAPIAction method within the WbEditingAction class by decomposing conditional logic into smaller methods (validateIfnewEntity, validateEditEntityDataUsingId, validateEditEntityData), focusing on core logic.
Extract Class - DataTypeJsonUtils
Introduced the DataTypeJsonUtils class to separate JSON conversion logic from execution logic, adhering to the Single Responsibility Principle.
Move Method - getReferenceUri
Improved design by moving getReferenceUri logic from Vocabulary to ReferenceRdfConverters, aligning responsibilities with the classes most directly involved.
Pull up Variable - constructTermMap and toTerm
Centralized the constructTermMap and toTerm methods by pulling them up into the StatementDocumentImpl class. This change eliminates duplication and simplifies constructTermMap across various inherited classes.
Each refactoring change preserves the existing functionality and interface contracts, ensuring backward compatibility and uninterrupted operation. The focus has been on internal improvements that enhance our code's structure without altering its behavior from an external viewpoint.
Your feedback and suggestions on these refactorings are welcome.