Presentation is loading. Please wait.

Presentation is loading. Please wait.

SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.

Similar presentations


Presentation on theme: "SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin."— Presentation transcript:

1 SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin

2 Agenda – Lecture 10b Review & renew. GRASP: GoF:
Solutions to Exercise Set 9: PCV-TS-TDG. GRASP: Polymorphism (review). Pure Fabrication. GoF: Singleton (review) Composite. From Requirements to design. 4/23/2019 SOEN 343, © P.Chalin,

3 Opening Remarks Bakary’s requestion: “in an exam can we invent classes like Person”. Person is an instance of the Domain Model pattern. Applications will have instances of the Domain Model pattern, not a class named “DomainModel”. Rene: for a definition of Controller, see Section 16.10, p. 237, first 13 lines. Chris: “delete” is not a reserved word in Java. Exams & memory. 4/23/2019 SOEN 343, © P.Chalin,

4 Do-it-all Servlet Redesign solutions: lect09.ppt SOEN 343, © P.Chalin,
4/23/2019 SOEN 343, © P.Chalin,

5 GRASP … Polymorphism. Pure Fabrication. Indirection.
Protected Variations. 4/23/2019 SOEN 343, © P.Chalin,

6 GRASP: Polymorphism Principle
Front Controller gives us an applied example of Larman’s polymorphism principle. Larman: When related alternatives or behaviors vary by type (class), assign responsibility for the behavior—using polymorphic operations—to the types for which the behavior varies. 4/23/2019 SOEN 343, © P.Chalin,

7 Code With Cascaded If’s
cmd = request.getParameter("command"); if(cmdName.equals(“AddStudent”)) { // Do addition … } else if( ... “RemoveStudent”)) { // Do removal … } ... else { // Error } FrontControllerServlet # processRequest ( ) + getUrlBase ( ) 4/23/2019 SOEN 343, © P.Chalin,

8 Front Controller (Fowler) Command (GoF) Patterns
FrontCommand + init ( ) + processRequest ( ) RemoveStudentCommand ViewStudInfoCommand + processRequest ( ) + processRequest ( ) 4/23/2019 SOEN 343, © P.Chalin,

9 GRASP: Pure Fabrication
Assign a highly cohesive set of responsibilities to an artificial or convenience class that does not represent a problem domain concept—something made up, to support high cohesion, low coupling, and reuse. Can you think of an example from EA? 4/23/2019 SOEN 343, © P.Chalin,

10 Gang Of Four Gamma, Helm, Johnson, Vlissides SOEN 343, © P.Chalin,
Erich 4/23/2019 SOEN 343, © P.Chalin,

11 GoF Pattern Summary (& Relationhips)
[Picutre (c) GoF CD] 4/23/2019 SOEN 343, © P.Chalin,

12 Converting C to a Singleton.
4/23/2019 SOEN 343, © P.Chalin,

13 Singleton Pattern Notice: Constructor is no longer public.
To access the instance use getUniqueInstance(). All other attribute and method declarations of C stay the same. 4/23/2019 SOEN 343, © P.Chalin,

14 «Singleton» C.getUniqueInstance()
public static C getUniqueInstance() { if(uniqueInstance == null) { uniqueInstance = new C(); } return uniqueInstance; 4/23/2019 SOEN 343, © P.Chalin,

15 Singleton: Design Alternatives/Issues
Create a class with static attributes and methods. Trade-offs: consider how easy the following are: Adapting the design so that x instances can be created (where x > 1). Subclassing. Passing the instance as a parameter. 4/23/2019 SOEN 343, © P.Chalin,

16 Singleton: Testing How to accommodate for the possibility of creating a Mock of a singleton? See martinfowler.com. 4/23/2019 SOEN 343, © P.Chalin,

17 Composite: Ex. Objects 4/23/2019 SOEN 343, © P.Chalin,

18 Composite: Ex. Class Diagram
4/23/2019 SOEN 343, © P.Chalin,


Download ppt "SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin."

Similar presentations


Ads by Google