Let’s see how classes can register themselves in a factory and what are the examples where it’s used.
by Bartlomiej Filipek
From the article:
In this post, I’ve covered a type of factory where types register themselves. It’s an opposite way of simple factories where all the types are declared upfront. Such approach gives more flexibility and removes dependency on the exact list of supported classes from the factory.