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

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



Jon Skeet [C# MVP] wrote:

If all the methods and properties in the class are static, the correct
denomination is "facade". In the facade pattern, the class acts as a
"wall" to "hide" the calls to objects. Facade classes are at the limit
between OOP and procedural programming, and should IMHO be used with
reason. To ensure that instantiation is impossible, facade classes have
a private default constructor.

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.
--
Tom Porterfield

.



Relevant Pages

  • Re: Why instantiate a class, all of whose methods, properties, and events are static?
    ... I'm learning the .net Bloomberg api, and it's main class has all of its ... denomination is "facade". ... That's not my understanding of the facade pattern. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Why instantiate a class, all of whose methods, properties, and events are static?
    ... 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. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Facade
    ... I've been thinking about the facade pattern lately, and it seems to me that ... one very good use for it is to implement one facade in every subsystem, ... from that namespace, simplifying things for 90% of clients in other ... the Facade can be a collection of abstract classes providing access to ...
    (comp.object)