He wants to make sure there will only be one class instance. Do some web searches for the Singleton Design Pattern. This is also a lazy loading design that doesn'tconstruct the instance until the first request comes in. After that, all future requests get the same instance and not a new one.
I can't check the source right now, but you may find that ArticlesProvider has no public constructor, since that would bypass the purpose of what we're trying to do if people could create their own instance.
Lastly, as if that weren't enough, he's dynamically fetching the type from the global settings and creating it based on that type. That allows the provider to change in the future without changing this source code.
Eric
|