Inspired on github ochococo/Design-Patterns-In-Swift
The factory pattern is used to replace class constructors, abstracting the process of object generation so that the type of the object instantiated can be determined at run-time.
Class Diagram for Currency Factory example (@ochococo)
I implemented a second example, the one present in Design Patterns book by Head First. An implementation in Java can be found in adagio/PizzaStores - factory method branch
There is a slight difference, between this two examples. The one from Head First considers Creator and Concrete Creator classes. We have implemented NYStylePizzaStore, but not a PizzaStore protocol.
- Factory Method, by 5Neo.Be. AppleProductCreator, iPhoneProductCreator, AppleProduct, iPadProduct...
- Factory Method, by zsergey st github. Developer Factory, SwiftDeveloperFactory, ObjCDeveloperFactory, Languages...
- The Factory Method Pattern, by Jeremy Kaczmarczyk. GameCreator, Game, Basketball1on1, StreetBasketball2on2...