From the course: Python: Design Patterns
Unlock this course with a free trial
Join today to access over 24,400 courses taught by industry experts.
Abstract Factory - Python Tutorial
From the course: Python: Design Patterns
Abstract Factory
- [Narrator] As its name suggests, abstract factory builds on the factory pattern. Abstract factory is useful when its user expects to receive a family of related objects at a given time, but doesn't have to know which family it is until runtime. Here is the scenario we'll be using. We'll first build a pet factory whose concrete factories include dog factory and cat factory. Both dog and cat factories produce dogs and cats as well as related products such as dog food and cat food. In theory, our solution abstract factory consists of abstract factory, concrete factory, abstract product, and concrete product. For the abstract factory, we use pet factory. For concrete factory, we use dog factory and cat factory. And finally, for the concrete products, we'll be creating dogs, the type of pet and dog food, and also cats and cat food. We implement our abstract factory without using inheritance because Python is a dynamically typed language and therefore does not require abstract classes…
Contents
-
-
-
-
(Locked)
Factory57s
-
Factory example7m 37s
-
Solution: Factory2m 37s
-
(Locked)
Abstract Factory1m 46s
-
(Locked)
Abstract Factory example5m 57s
-
(Locked)
Singleton1m 39s
-
Singleton example7m 17s
-
(Locked)
Solution: Singleton2m 20s
-
(Locked)
Builder2m 3s
-
(Locked)
Builder example5m 59s
-
(Locked)
Prototype1m 30s
-
(Locked)
Prototype example7m 18s
-
(Locked)
-
-
-
-