Is this a Facade ?
Hello friends,
Should I say that the Manager acts as a Facade ?
publicclass A
{
publicvoid methodInClassA()
{
}
}
publicclass B
{
publicvoid methodInClassB()
{
}
}
publicclass Manager
{
privatefinal A a;
privatefinal B b;
public Manager()
{
a =new A();
b =new B();
}
publicstaticvoid main(String args[])
{
Manager manager =new Manager();
manager.execute();
}
publicvoid execute()
{
a.methodInClassA();
b.methodInClassB();
}
}
Thanks in advance.
I don't think so. a facade makes an API or a set of related objects easier to use. since the "API" in this example is just a couple of void methods, with no parameters, you're not simplifying anything, merely cutting down on keystrokes to invoke those methods; even then, the overhead in creating the Manager class outweighs those keystrokes. but a facade is not about cutting down keystrokes
also, since there is no apparent relationship between classes A and B, we can't really consider their respective methods to constitute an API
You should think of OO terms more artfully than scientifically. You may call it a facade if you wish. If that is what you designed it to be. It helps to communicate the intent. its rather simplistic and not very useful as a facade IMHO. nevertheless, if that was your intent, then yes, you may call it a facade.