Re: Why instantiate a class, all of whose methods, properties, and events are static?
- From: "Tom Porterfield" <tpporter@xxxxxxxx>
- Date: Thu, 5 Oct 2006 08:28:17 -0400
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
.
- Follow-Ups:
- Re: Why instantiate a class, all of whose methods, properties, and events are static?
- From: Laurent Bugnion, GalaSoft
- Re: Why instantiate a class, all of whose methods, properties, and events are static?
- References:
- Why instantiate a class, all of whose methods, properties, and events are static?
- From: sherifffruitfly
- Re: Why instantiate a class, all of whose methods, properties, and events are static?
- From: Laurent Bugnion
- Re: Why instantiate a class, all of whose methods, properties, and events are static?
- From: Jon Skeet [C# MVP]
- Why instantiate a class, all of whose methods, properties, and events are static?
- Prev by Date: Re: Fastest way to work with DataTable
- Next by Date: Re: UrlDecode
- Previous by thread: Re: Why instantiate a class, all of whose methods, properties, and events are static?
- Next by thread: Re: Why instantiate a class, all of whose methods, properties, and events are static?
- Index(es):
Relevant Pages
|