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

Apply SOLID principle at Door code example #133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tonicospinelli
Copy link

Many examples on the internet of software engineering didn't apply
the SOLID principle correctly. Considering the Doors could be made
in many kinds of materials, it sounds more like an Abstract class.

The changes there introduced will be explained over the SOLID
principle:

  • A Measurable Interface is a behavior expected for all objects which
    have dimensions, fitting to the Interface Segregation Principle.
  • Abstract Door has dimensions and requires a material to be built.
    It is a requirement for the Single Responsibility Principle.
  • Wooden Door is the concrete implementation over Door abstraction
    where defines its material and dimensions. This is an example of the
    Open/Close Principle.

Many examples on the internet of software engineering didn't apply
the SOLID principle correctly. Considering the Doors could be made
in many kinds of materials, it sounds more like an Abstract class.

The changes there introduced will be explained over the SOLID
principle:
* A Measurable Interface is a behavior expected for all objects which
have dimensions, fitting to the Interface Segregation Principle.
* Abstract Door has dimensions and requires a material to be built.
It is a requirement for the Single Responsibility Principle.
* Wooden Door is the concrete implementation over Door abstraction
where defines its material and dimensions. This is an example of the
Open/Close Principle.
@tonicospinelli
Copy link
Author

thanks to create this repo, here is my quick and humble contribution.

@abdallahisham
Copy link

abdallahisham commented Mar 29, 2023

@tonicospinelli great participation, but one notice
I think you breaked one of SOLID principles -which is Dependancy Inversion- when you set material within the constructor, better set it when calling the make door

@tonicospinelli
Copy link
Author

@abdallahisham, I understand your point. You are probably looking at the code on the SOLID principles aspects. I invite you to look at the code on the Object-Oriented approach. The Door is an abstract object with measures, and the WoodenDoor is a concrete object that never will be a MetalDoor. Now, does it make sense?

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.

2 participants