Skip to content

Refactor Code to SOLID #108

Open
Open
@SanLlerena

Description

@SanLlerena

Project: SimpleJavaCalculator
File Affected: Calculator.java

Description
With the intention of implementing SOLID principles in the code, there is a violation of the SRP within the class, to solve the following change was proposed where the mathematical operations will be performed in another class.

SRP

Also, to avoid OCP, classes were created with the mathematical operations to be performed, if you want to implement new functions, only the class with the new operation is created. The classes already defined are not modified.

OCP

To avoid problems with LSP, 2 clear interfaces were defined that will be implemented by the operations according to the amount of information they need.

LSP

Finally, to respect the DIP principle, the class depends on abstractions and not on defined implementations, avoiding problems in the code flow.

DIP

Additional Notes:
I have a branch where the mentioned changes were made, packages and other necessary classes were added to keep the project in SOLID design principles.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions