Re: IoC and Encapsulation

peter royal <[email protected]> Fri, 26 Mar 2004 09:13:20 -0500
Newsgroups gmane.comp.java.jcontainer.interest
Message-ID <[email protected]>
On Mar 26, 2004, at 4:32 AM, anders.janmyr wrote:
> By forcing the client to create these objects I force it to know more
> than it has to just to isolate myObject thus violating the principle
> of encapsulation.
>
> What are the best practices for using IoC?
> Should I use default values for clients with simple needs?
> Should I use a convenience factory method?
> Should I use a facade like class to hide my internals?

You are on the right track, and are asking the right questions..

You could create a factory for it.. myObjectFactory, and the client 
would just use that. or you could use one of the simple embeddable 
containers, such as picocontainer, and put myObject and all of its 
dependencies in the container and have the client retrieve myObject 
from the container (or even hide the container behind a factory / some 
type of facade)
-pete
smime.p7s (application/pkcs7-signature, 2.3 KB) - not displayed