dimanche 20 septembre 2020

how to combine singleton and factory design pattern with python?

Suppose there are several presses, each one published many books I am going to handle many records like 'press name, book name'

I want create the class 'Press' by a unique name(string), but only different string can produce different instances of class 'Press'.

so, I need a class work like 'factory', create a new instance when a record contains a new press, but it also work as singleton if there are already exists which has the same names.

Aucun commentaire:

Enregistrer un commentaire