Upload
anthony-ferguson
View
218
Download
0
Embed Size (px)
DESCRIPTION
CSC /30/2002 Design Pattern Space
Citation preview
CSC 480Software Engineering
Lab 5 – Abstract Factory PatternOct 30, 2002
CSC 480 210/30/2002
The Abstract Factory Pattern
Intent – provide an interface for creating families of related or depended objects without specifying their concrete classes
AKA Kit Like other creational patterns, this pattern can
help to avoid hard-coding the way in which objects need to be created
CSC 480 310/30/2002
Design Pattern Space
CSC 480 410/30/2002
Structure – an illustration
CSC 480 510/30/2002
Application – pluggable look-and-feel
Support multiple look-and-feel user interfaces, such as Windows, Motif, Macintosh Specify the selected look-and-feel in client programs The corresponding GUI factory will be returned to
generate graphical components in the requested laf In Java, this is accomplished at the system level
UIManager.setLookAndFeel(plafName);
CSC 480 610/30/2002
Look-and-Feel Alternatives
Windows
Motif
Metal (swing’s default)
CSC 480 710/30/2002
Application in This Lab
A GardenMaker Factory Garden varieties: annual, perennial, vegetable Common concerns
What are good center plants? What are good border plants? What do well in partial shade?
Plants With a name Other properties can be added
CSC 480 810/30/2002
Major Classes
CSC 480 910/30/2002
Sample Results
CSC 480 1010/30/2002
Consequences Benefits
It isolates concrete classes at the client level A factory encapsulates the responsibility and the process of
creating product objects. Clients are isolated from implementation classes
It makes exchanging product families easy – the concrete factory is used once
It promotes consistency among products Liabilities
supporting new kinds of products is difficult