lundi 14 mars 2022

Is this the Abstract Factory pattern or something else?

I have an abstract class that's following the singleton pattern, then I have a few concrete classes that extend it:

UML Diagram

At startup, based on the current system, I'm setting a concrete instance as the instance of the singleton like this:

LicenseFactory.setInstance(new SystemALicenseFactory())

With that, at any point in the code, I can consume the abstract method like this: LicenseFactory.getInstance().isUserValid()

Because my concrete classes aren't creating a product, I'm not sure whether I can call this the Abstract Factory pattern or something else. Is it common to use a pattern like this, and is there anything I should have done better?

Aucun commentaire:

Enregistrer un commentaire