From the course: Python: Design Patterns
Unlock this course with a free trial
Join today to access over 24,500 courses taught by industry experts.
Factory - Python Tutorial
From the course: Python: Design Patterns
Factory
- [Narrator] Factory encapsulates object creation. That is factory is an object specializing in creating other objects. The factory pattern is useful, especially when you're not sure about what type of objects you'll be needing eventually in your system. Another possibility is that your application needs to decide on what class to use at runtime. Here is a scenario we'll be using in our coding exercise. Your pet shop was only selling dogs, but now, you need to sell cats too. Therefore, your system needs to be able to handle cats as well as dogs. It's supposed to show how each of the pets you sell speaks.
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)
-
-
-
-