Presentation is loading. Please wait.

Presentation is loading. Please wait.

Creational Design Patterns Feb 4 2003 Lecture 15.

Similar presentations


Presentation on theme: "Creational Design Patterns Feb 4 2003 Lecture 15."— Presentation transcript:

1 Creational Design Patterns Feb 4 2003 Lecture 15

2 February 3 2003Lecture 142 Outline  Previous Business – HW3 – Visitor In visitorFinal example: FlattenVisitor  New Business – Group discussions for HW3

3 February 3 2003Lecture 143 Abstract Factory  Remove fixed reference to concrete class  Pull together a family of objects that must be created, and consistently construct them if (locale == 1) { add (new Button (“Close”)); } else if (locale == 2) { add (new Button (“Schließen”); } else if (locale == 3) { add (new ButtoN (“csukott”)); } add (factory.createCloseButton()); if (locale == 1) { add (new Button (“Register”)); } else if (locale == 2) { add (new Button (“Zum Anderlung”); } else if (locale == 3) { add (new ButtoN (“számláló”)); } add (factory.createRegisterButton());

4 February 3 2003Lecture 144 Factory Method  Defer instantiation to subclasses  Abstract classes control relationships  Subclasses responsible for instantiating objects if (locale == 1) { add (new Button (“Close”)); } else if (locale == 2) { add (new Button (“Schließen”); } else if (locale == 3) { add (new ButtoN (“csukott”)); } add (createCloseButton()); Button createCloseButton () { return new Button (“Close”); } Button createCloseButton () { return new Button (“Schließen”); }

5 February 3 2003Lecture 145 Group Discussion  Big Picture Idea  >  Keep notes and give to me on rough ideas and problems you foresee.


Download ppt "Creational Design Patterns Feb 4 2003 Lecture 15."

Similar presentations


Ads by Google