3 ms·
I prefer to mix both dependency injection and singletons for the best of both words. Classes accept dependencies in their constructors but as optional paramete
by wvenable 14y ago
I prefer to mix both dependency injection and singletons for the best of both words. Classes accept dependencies in their constructors but as optional parameters -- if the parameter isn't provided, a default reference is pulled from a singleton.
It saves a lot of extra typing when 99% of the time your dependencies are fixed.