Re: Why instantiate a class, all of whose methods, properties, and events are static?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi,

Tom Porterfield wrote:
Jon Skeet [C# MVP] wrote:

That's not my understanding of the facade pattern. To me, the facade
pattern just presents a simpler interface, quite possibly still
involving creating an instance.


I agree with Jon. Facade pattern and whether or not methods are static are not related. The Facade pattern is a way to create a simple interface on top of a complex system. An example would be if you have a fairly common operation to perform that requires some complex coordination among other objects. You don't want to do this coordination each time you want to perform the operation. So you can create a facade class that exposes simple method that does the complex coordination for you. Then you just create an instance of the facade class, call its simple method and let it worry about what is required to actually perform the action. The method might be static or not, that is a design decision to be made based on other criteria.

I have seen imlpementations of facade classes that take in the objects they are going to coordinate in the constructor. This allows for reuse, especially if designed to interfaces rather than concrete classes. But again, the implementation will depend on the needs of the specific scenario.

Interesting. I got to say, I always thought of Facades as static classes, with the exact purpose that you state, i.e. providing a simpler access to a complex system. I never thought of making them non-static. Or, rather, I already made such non-static classes, but I never thought of them as facades ;-)

Thanks for clarifying.

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
.



Relevant Pages

  • Facade pattern
    ... I'm a little confused about the Facade pattern. ... it, it's supposed to be a single, simplified interface into a larger ... contains the core business objects and Managers for those objects. ... its filter to the data, listen for events from the Model of when data ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Newbie Modelling Interface Question
    ... >>different interfaces for different client contexts, ... >>Facade wrapper, ... How do these approaches expose the subsystem ... > point of an interface was to prevent exposing the implementation. ...
    (comp.object)
  • Re: Encapsulating user interface
    ... will have classes like Window, Dialog, and Control. ... Because that mapping is not 1:1... ... Then passing the Facade to objects that need to send data ... That implies there is a pure message interface (i.e., ...
    (comp.object)
  • Re: Why instantiate a class, all of whose methods, properties, and events are static?
    ... Jon Skeet wrote: ... denomination is "facade". ... Facade pattern and whether or not methods are static are not related. ... An example would be if you have a fairly common operation to perform that requires some complex coordination among other objects. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Newbie Modelling Interface Question
    ... subsystem interfaces that could be interpreted as a pattern. ... They present a fixed interface to the outside world. ... Now the Xout interface is also a Facade. ...
    (comp.object)