Re: Why instantiate a class, all of whose methods, properties, and events are static?
- From: "Laurent Bugnion, GalaSoft" <galasoft-lb@xxxxxxxxxx>
- Date: Sat, 07 Oct 2006 22:41:17 +0200
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
.
- 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]
- Re: Why instantiate a class, all of whose methods, properties, and events are static?
- From: Tom Porterfield
- Why instantiate a class, all of whose methods, properties, and events are static?
- Prev by Date: Re: C# equivalent to a smart pointer???
- Next by Date: Re: C# equivalent to a smart pointer???
- Previous by thread: Re: Why instantiate a class, all of whose methods, properties, and events are static?
- Next by thread: Timer Array in c#, VS2005
- Index(es):
Relevant Pages
|