Design patterns are wonderful tools software masters bring
to us, which are based upon the object oriented programming. As one of the
mostly used design patterns, the Factory Method pattern is also widely
leveraged in designing the numerous .NET Framework classes.
In this article, we first introduced the basic idea of the
Factory Method pattern with a simple graphic related example. Then, we started
to explore the behind implementation of one of the most important web classes--
WebRequest. By seeking after the detailed code related to class WebRequest we
have finally dug out the design routine of class WebRequest and tasted the wonderful
utilization of the Factory Method pattern.
One last note: I have omitted all the WebRequest associated
code in the source code file, so I highly recommend you to pick up Red Gate's .NET Reflector (originally
developed by Lutz Roeder) to find out all the related things.