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

Application of the Factory Method design pattern to solve the creation of objects related to the order flow. #8

Open
Darwin4050E opened this issue Dec 15, 2024 · 0 comments

Comments

@Darwin4050E
Copy link

Problem description:

Currently, the creation of objects such as events is distributed directly in the PizzaKitchen code, which increases coupling and makes it difficult to extend for new types of events or pizzas. This violates the single responsibility principle, since PizzaKitchen performs both business logic and object construction.

Proposed Solution:

  • Implement the Factory Method pattern to encapsulate the creation of events.
  • Create a factory to generate Event instances based on the current state of the order.
  • Modify PizzaKitchen to delegate the creation of these objects to the respective factories.

Consequences or implications of the redesign:

Advantages:

  • Decoupling of object creation and business logic.
  • Easier to add new types of events.
  • Better maintenance and adherence to the single responsibility principle.

Impacts:

  • Minimal changes to current code; new classes are added without significantly affecting existing logic.

Resources:

UML Diagram:

FactoryMethodPizzaKitchen

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

No branches or pull requests

1 participant