The Flyweight
design pattern has a Factory, but it does not follows the Factory
pattern, so why it is called Factory
?
I mean:
- The
Factory
method has a main purpose/method and the creation of the object inside of the method depends on the subclass that inherits it. - The
Abstract Factory
has Factories that creates objects based on their divisions/families. - The
Simple Factory
has a method that, depending on a condition, it creates a new object with some specific properties/configuration
So:
- Why it’s called
Factory
on theFlyweight
pattern if it acts as a cache and not a creation method?