vendredi 18 mai 2018

When should I use Singleton pattern?

As far as I know the singleton design pattern should be used when a class must have at most one instance. In my project, which is an e-shop, I use entities like 'User', 'Order', 'Cart' and I think that the singleton pattern is the case for each one of my previous entities. For example, the following scenario is very common for an e-shop.

One User has one Cart and makes an Order.

Have I misinterpret the Singleton pattern?

Aucun commentaire:

Enregistrer un commentaire