This preview shows page 1. Sign up to view the full content.
Unformatted text preview: return new MacMenu;
64 Pattern Pattern Diagram for product classes Glyph Abstract Factory pattern Name Abstract Factory or Kit Applicability ... Button
PopUp() Different families of components (products) must be used in mutually exclusive fashion and consistently Hide existence of multiple families from clients e.g., MotifFactory, MacFactory, etc. Structure MotifButton
65 Combine two previous diagrams and add arcs signifying object creation from factory classes to product classes 66 Pattern
CreateProductA() CreateProductB() Pattern ...
ProductA1 ProductA2 Structure of Abstract Factory Abstract Factory (cont d) ...
CreateProductA() CreateProductB() ConcreteFactory2
CreateProductA() CreateProductB() Consequences 1. Isolate creation and handling of instances from clients 2. Changing look-and-feel standard at run-time is easy Just reassign a global variable; recompute and redisplay interface AbstractProductB ...
67 3. Enforces consistency among products in each family 4. Supporting (adding) new family of products is difGicult Not an orthogonal set of classes 68 Supporting user commands Case study Case study Support execution of Lexi commands, with following reqs: 1. Different commands have different interfaces 2. Same command can be invoked in different ways by user 3. Some commands should support Undo and Redo functionality, some should not (e.g., Gile commands) Obvious solution: Associate operations with user interface actions! Of course, this is BAD, BAD, BAD No support for (2) and (3) above Also, proliferation and coupling of classes (each command likely to be implemented by several classes) 69 Supporting user commands (cont An improved solution d) Action-performing glyphs are subclasses of a special Glyph subclass that takes command Instances of Glyph subclass can parameterize command execution by passing a function name denoting code that executes command Problems still: 1. Passing context to the command function (e.g., different commands will have different interfaces) 2. Undo and Redo not adequately supported yet 70 Case study Supporting user commands (cont Key idea: Pass an...
View Full Document
This note was uploaded on 02/23/2012 for the course COMP 553 taught by Professor Ajay during the Spring '12 term at Ill. Chicago.
- Spring '12