[Cs3] CS3 - Abstract Factory and singleton
Mikhail Nesterenko
mikhail at cs.kent.edu
Wed Dec 8 21:58:37 EST 2021
>
> I hope this email finds you well. I am reaching out to seek assistance with
> a question I am confused about. The Singleton pattern is basically to
> ensure that there is only one instance of a class and it provides a global
> point of access to it while an abstract factory pattern is to design an
> interface to create families of related objects without specifying the
> concrete classes. So, how is the singleton class an example of the factory?
>
A factory is an object (or a class) that generates other objects,
called products. This is done to hide the process of object
creation. There is usually a method, called "factory method", that
returns a pointer or a reference to the product. In this sense, the
Singleton Pattern is an example of a factory, the method "instance()"
returns the "product" which is the singleton object.
The Abstract Factory Pattern indeed contains an abstract factory
interface an ad family of concrete factories that generate similar
products. So the Abstract Factory Pattern is more sophisticated than
just a simple factory.
Thanks,
--
Mikhail
More information about the cs3
mailing list