Skip to content

State Pattern violate Liskov Substitution Principle #283

@ko22009

Description

@ko22009

https://github.com/domnikl/DesignPatternsPHP/blob/master/Behavioral/State/ShippingOrder.php#L22
https://github.com/domnikl/DesignPatternsPHP/blob/master/Behavioral/State/CreateOrder.php#L28

Refactoring code to create interfaces which is seperate completeOrder and shipOrder.

Maybe will be useful https://softwareengineering.stackexchange.com/questions/181922/does-the-state-pattern-violate-liskov-substitution-principle

And also you have bad style and you code is not maintainable: https://github.com/domnikl/DesignPatternsPHP/blob/master/Behavioral/State/OrderRepository.php#L24
You can create class which is implement the same interface and pass your created objects(CreateOrder and ShippingOrder) - DI. Override interface class in your new class and call your parent method there. (you can apply decorator there too)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions