lundi 27 juin 2016

Where to create interface implementation?

I'm gonna ask perhaps simple an OO design question.

Imagine we inversed a dependency between two concrete classes ( Foo and Hoo ) using an interface (IHoo) where Hoo implements the interface and Foo uses that implementation.

At that point, I wondered where excatly I should attach that implementation ( Hoo ) to it's client ( Foo ). Obviously, if we add Hoo in the client class Foo, then we have not inversed the compile-time dependency ( with respect to runtime dependency ) and we have only made a bit more modular code, but not less-rigid.

So perhaps, we associate client and the interface implementation in a master ( or higher-level ) class like a controller or so? What's your approach would be ?

Thx.

Aucun commentaire:

Enregistrer un commentaire