caching object ?



greetings,

I'm developping an application and am thinking about the following problem :
instance A needs instance B and C.
instance D needs B and C
instance E needs C


now I could do the following :
create A and feed him B, C
create D and feed him B and C or feed him A (since A holds B,C)
create E and feed him A(since A holds B,C) or C only.

this creates dependencies so, having read about spring and IOC but not willing to use it (because I didn't managed to make spring work under dotnet in fact :) ).
I did this :


create some container which will contain A,B,C,D,E
this container will give a reference to himself to each of the objects.

now, whenever any object need any object, he just uses the reference contained in this.container.

The point is the following :

the container can contain objects which are totally useless to some objects : E doesn't care about B for example.

I'm quite happy with this thing becase, I do not have complex dependencies of my objects : they all depend of one object only, the container.

what are your remarks about this ? (I am still young to OOP :) )

But



.