Skip to Content
Learning Python Design Patterns - Second Edition - Second Edition
book

Learning Python Design Patterns - Second Edition - Second Edition

by Chetan Giridhar, Gennadiy Zlobin
February 2016
Beginner to intermediate
164 pages
3h 25m
English
Packt Publishing
Content preview from Learning Python Design Patterns - Second Edition - Second Edition

The Simple Factory pattern

For some, Simple Factory is not a pattern in itself. It is more of a concept that developers need to know before they know more about the Factory method and Abstract Factory method. The Factory helps create objects of different types rather than direct object instantiation.

Let's understand this with the help of the following diagram. Here, the client class uses the Factory class, which has the create_type() method. When the client calls the create_type() method with the type parameters, based on the parameters passed, the Factory returns Product1 or Product2:

The Simple Factory pattern

A UML Diagram of Simple Factory

Let's now understand the Simple ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Python Design Patterns - Second Edition

Mastering Python Design Patterns - Second Edition

Kamon Ayeva, Sakis Kasampalis
Advanced Python Programming

Advanced Python Programming

Dr. Gabriele Lanaro, Quan Nguyen, Sakis Kasampalis

Publisher Resources

ISBN: 9781785888038Supplemental Content