Creational Design Patterns in Python

python_tutorials

Overview

This is the first article in a short series dedicated to Design Patterns in Python.

Creational Design Patterns

Creational Design Patterns, as the name implies, deal with the creation of classes or objects.

They serve to abstract away the specifics of classes so that we’d be less dependent on their exact implementation, or so that we wouldn’t have to deal with complex construction whenever we need them, or so we’d ensure some special instantiation properties.

They’re very useful for lowering the level of dependency between our classes and controlling how the user interacts with them as well.

The design patterns covered in this article are:

Factory

Problem

Say you’re making software for an insurance company which offers insurance to people who’re employed full-time. You’ve made the application using a class called Worker.

However, the client decides to expand their business and will now provide their services to unemployed people as well, albeit with different procedures and conditions.

Now you have to make an entirely new class for the unemployed, which will take a completely different constructor! But now you don’t know which constructor to call in a general case, much less which

To finish reading, please visit source site