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

Codebase Refactoring for Improved Readability and Maintainability #861

Closed
wants to merge 4 commits into from

Conversation

risvarrt
Copy link

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.

Copy link
Member

@wetneb wetneb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @risvarrt,
I am curious what brought you to work on this. Is it for an assignment at university perhaps?
Or do you need such refactorings yourself to enable further improvements to WDTK? Which ones?
I had a quick look at the changes and I don't understand why they'd be improvements, but perhaps I can relate better to your needs once you give me a bit more background on what brought you to submitting this.
Thank you!

@risvarrt
Copy link
Author

risvarrt commented Apr 4, 2024

Yes, It is a part of my assignment. Also, I wanted to apply my learnings on refactoring and code smells on this repository
Let me know if any other changes are needed here.

@wetneb
Copy link
Member

wetneb commented Apr 4, 2024

Ok. Would you be able to share the detailed instructions you have been given for this assignment?

@wetneb wetneb closed this May 17, 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.

None yet

2 participants