10
CSC 480 Software Engineering Lab 5 – Abstract Factory Pattern Oct 30, 2002

CSC 480 Software Engineering Lab 5 – Abstract Factory Pattern Oct 30, 2002

Embed Size (px)

DESCRIPTION

CSC /30/2002 Design Pattern Space

Citation preview

Page 1: CSC 480 Software Engineering Lab 5 – Abstract Factory Pattern Oct 30, 2002

CSC 480Software Engineering

Lab 5 – Abstract Factory PatternOct 30, 2002

Page 2: CSC 480 Software Engineering Lab 5 – Abstract Factory Pattern Oct 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

Page 3: CSC 480 Software Engineering Lab 5 – Abstract Factory Pattern Oct 30, 2002

CSC 480 310/30/2002

Design Pattern Space

Page 4: CSC 480 Software Engineering Lab 5 – Abstract Factory Pattern Oct 30, 2002

CSC 480 410/30/2002

Structure – an illustration

Page 5: CSC 480 Software Engineering Lab 5 – Abstract Factory Pattern Oct 30, 2002

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);

Page 6: CSC 480 Software Engineering Lab 5 – Abstract Factory Pattern Oct 30, 2002

CSC 480 610/30/2002

Look-and-Feel Alternatives

Windows

Motif

Metal (swing’s default)

Page 7: CSC 480 Software Engineering Lab 5 – Abstract Factory Pattern Oct 30, 2002

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

Page 8: CSC 480 Software Engineering Lab 5 – Abstract Factory Pattern Oct 30, 2002

CSC 480 810/30/2002

Major Classes

Page 9: CSC 480 Software Engineering Lab 5 – Abstract Factory Pattern Oct 30, 2002

CSC 480 910/30/2002

Sample Results

Page 10: CSC 480 Software Engineering Lab 5 – Abstract Factory Pattern Oct 30, 2002

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