I have a class named MyClass
in subsystem A, and a method in subsystem B has arguments of type MyClass
. My subsystems are highly coupled, so I want to make a Facade for subsystem A. Should I somehow pass the MyClass
type trough the Facade? What is the right way?
thanks
It depends (tm), but it's usually a good idea to have separate classes that are used by an API and classes that are internal to the system. If for whatever reason MyClass
needs to change in System A, you probably don't want that change to cascade and impact System B.
In your example, if each subsystem should be as loosely coupled as possible, one approach would be to have an adapter that is external to both subsystems, but it's able to adapt the calls from one to the other.
Just a word of caution, overusing design patterns is not a good idea. I think in your example it's worth asking oneself if the subsystems should be separate or if they are one.