What is the best practice on setting and keeping these "global" objects ?
I have encountered this problem couple of times with
ORM session object (XPO from DevExpress)
IOC container (Microsoft.Unity)
Logger (from The Object Guy)
I have come up with three options on how to deal with this:
Dependency injection. This looks extremely cumbersome to me and I feel like every class is bloated by extra three getters/setters that all almost all the classes would use. On the other hand it gets rid of the global variables fear and makes the code bits less dependant of each other.
Create a static class (for example ContainerKeeper) that is settable once and returns the kept object. I know this resembles a singleton and I should use singleton instead.
Using a Singleton pattern. I've read some discussion against the use of singletons and how bad they are etc. so I am frankly unsure how many principles of good OO design will I break by using one in these cases.
So my question rephrased is :
Is there some other option, Am I completely off the track ? How would you do it ?