Chapter 8 -- Object Factory

[Previous] [Next]

Chapter 8

We can all appreciate the main benefit of being able to plug a product, anything from a rice steamer to a chain saw, into an electrical outlet. Despite the radical differences in behavior among such products, they all function without fail once they're plugged in (assuming you have a live power supply and an otherwise functioning product). This plug-and-play ability allows us to enjoy quite an extensive list of amenities. Product manufactures can develop new products that are guaranteed to function with any standard electrical outlet. Most of us can't imagine life without electricity, but a device that requires electricity to operate that doesn't plug into a standard electrical outlet is useless in the average household. You can infer from this that the concept of electric-powered products has been successful because of the standard interfaces designed for supplying and consuming electricity. Having a standard interface enables a manufacturer to produce products with varying behavior, which translates to various benefits experienced by the user. The system producing the electricity is oblivious to the behavior and the resulting benefits of these products. The system's only requirement is that any product needing electricity must support the interface expected by the electrical system.

This plug-and-play concept can also be applied to developing object-oriented software systems. A client application (the electrical system) can reference any class of object (the product) that supports the interface (the plug) it expects. Implementing plug-and-play functionality in a software system allows you to dynamically introduce new behavior into the system. For this implementation to be possible, the client application must be oblivious to the objects that support the interface it expects. The Object Factory design pattern is the means by which you accomplish this end.



Microsoft Visual Basic Design Patterns
Microsoft Visual Basic Design Patterns (Microsoft Professional Series)
ISBN: B00006L567
EAN: N/A
Year: 2000
Pages: 148

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net