View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Fall 04 Midterm 2 Review: Design Patterns

a)
Both types of Factory Patterns are similar in that they create objects "on the fly", so to speak. Specifically, an object is asked to be created but the type of object is unknown. The Factory lets its subclasses take care of the creation, thereby asking a Factory for something you want and it spitting it back out.

The differences lie in just what is created. The factory creates an object by sending the request down to its subclasses. The Abstract Factory creates families of related or dependent objects. The example given in the slides involves a CartPartFactory with specific Factories internally for the specific kind of part for the specific car. To my understanding, the Abstract Factory is the same as the Factory Pattern, but abstracted out even further.

because this will be better than any explanation i could give: http://www.dofactory.com/Patterns/PatternFactory.aspx and http://www.dofactory.com/Patterns/PatternAbstract.aspx and its a good resource (just click the "back to design patterns" link in the upper right) -ellie

b)
Both the Adapter and Bridge patterns are built to alter the way one object communicates with another. However, the method in which this is done is the difference.

In the case of the Bridge, two objects are separated through a "bridge". This bridge basically allows the abstraction of the two objects from each other and allows them to be fully independent.

The Adapter, however, merely wraps an individual object to be able to communicate with another object, literally an adapter.

It seems, however, that it may be possible to accomplish a Bridge pattern with an Adapter, but I could be crazy.

not sure, the focus of the adapter pattern is converting the interface of a class into something a client expects, while the bridge pattern separates the interface from the implementation. -ellie


Link to this Page