0

So I want to write a code that follows the OO Principles for a restaurant menu, like: sandwiches: 3 different types drinks: 5 different types and so on, and I thought using the factory method design pattern is the best? do you agree with that? or is it abstract factory will do it better?

  • Possible duplicate of [Differences between Abstract Factory Pattern and Factory Method](https://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method) – Rick Riensche Jan 16 '18 at 22:08

1 Answers1

0

Factory pattern is used to encapsulate and potentially hid the logic needed to create esp complex objects. If this is ur intend it would be applicable

Depending on ur further context it may make sense to use multiple factories. One per "type" of things. E.g. one for drinks and one for sandwiches

plainionist
  • 2,950
  • 1
  • 15
  • 27
  • so I can't make the factory to create different objects and each object have a different family ? – user3019158 Jan 16 '18 at 22:01
  • U can also have one factory class with e.g. 2 factory methods. One for drinks and one for sandwiches. Whether that is suitable depends on ur further context – plainionist Jan 16 '18 at 22:04
  • Thanks, actually that is what I was intending to do, to make one factory and it produces different families depending on different methods. – user3019158 Jan 17 '18 at 13:56