mercredi 1 juin 2016

Does facade class in facade pattern need to be static?

I was going through MSDN article about facade pattern. http://ift.tt/22yThvY

I couldnt find reason why they made facade a static class ? Why they used static variables to hold instances of subsystem classes ? Why did they use static methods ? I would like to know reason behind it.

Below is the static code section from that article. Full code can be found inside article.

public static class Facade 
{
     static SubsystemA a = new SubsystemA(  );
     static SubsystemB b = new SubsystemB(  );
     static SubsystemC c = new SubsystemC(  );

     public static void Operation1(  ) {
       Console.WriteLine("Operation 1\n" +
           a.A1(  ) +
           a.A2(  ) +
           b.B1(  ));
    }

     public static void Operation2(  ) {
       Console.WriteLine("Operation 2\n" +
           b.B1(  ) +
           c.C1(  ));
     }
   }

Aucun commentaire:

Enregistrer un commentaire