lundi 15 février 2016

How to adapt the facade design pattern with additional properties and functions (different namespace)

I would to get your feedback regarding on the best approach to what I have in mind. Example: in my namespace.Core I have a Facade class. Then, I have a "client" in namespace.Client that is "consuming" the facade.

public class Facade
{

PUBLIC SubSystemOne _one;
PUBLIC SubSystemTwo _two;
PUBLIC SubSystemThree _three;
PUBLIC SubSystemFour _four;

public Facade()
{
  _one = new SubSystemOne();
  _two = new SubSystemTwo();
  _three = new SubSystemThree();
  _four = new SubSystemFour();
}

public void MethodA()
{

  Console.WriteLine("\nMethodA() ---- ");
  _one.MethodOne();
  _two.MethodTwo();
  _four.MethodFour();
}

public void MethodB()
{
  Console.WriteLine("\nMethodB() ---- ");
  _two.MethodTwo();
  _three.MethodThree();
}

}

Now, I would like to keep the "core" closed.... and by creating "add-ons" from other "class libraries" (namespace.AddOn1, namespace.AddOn2, etc....) add additional "SubSystemXXX" that are still "visible" to the "client".....

This is easy to make, if every addOn is inside of the same namespace, in that way I could use a "partial" class, but this is not possible on the moment that I use different class libraries.....

I would not like to use the decorator patter, because then I would need to add always a different "new decorator solution" for each new add-on.... or maybe I am wrong on this one.....

Anyway, it would be nice to read some alternatives.....

The important part for me, is to be able to add the "new" public properties "SubSystemXXx" and the client be able to view all of them......

If my question is not clear, please tell me and I will clarify my idea.

Thanks

Aucun commentaire:

Enregistrer un commentaire