SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler

Slides:



Advertisements
Similar presentations
Chapter 6 Server-side Programming: Java Servlets
Advertisements

Object-Oriented Analysis and Design CHAPTER 17, 25: GRASP PATTERNS 1.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
Chapter 25 GRASP: More Objects with Responsibilities 1CS6359 Fall 2011 John Cole.
NJIT More GRASP Patterns Chapter 22 Applying UML and Patterns Craig Larman Prepared By: Krishnendu Banerjee.
Satzinger, Jackson, and Burd Object-Orieneted Analysis & Design
GRASP : Designing Objects with Responsibilities
Feb 4, Ron McFadyen1 founded on principles of good OO design idea was first put forth by Christopher Alexander (1977) in their work concerning.
Course Instructor: Aisha Azeem
Java Servlets. What Are Servlets? Basically, a java program that runs on the server Basically, a java program that runs on the server Creates dynamic.
COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler
COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler
Chapter 13 Starting Design: Logical Architecture and UML Package Diagrams.
1/19 Component Design On-demand Learning Series Software Engineering of Web Application - Principles of Good Component Design Hunan University, Software.
GRASP Principles. How to Design Objects The hard step: moving from analysis to design How to do it? –Design principles (Larman: “patterns”) – an attempt.
Todd Snyder Development Team Lead Infragistics Experience Design Group.
Chapter 17. GRASP General Responsibility Assignment Software Patterns (Principles) OOD: after identifying requirements, create domain model, define responsiblities.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
1 SAD2 - UML 4 th Lecture Class Diagram in Construction Phase Patterns Case Study Lecturer: Dr Dimitrios Makris
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
Architecture GRASP Realization of use cases in interaction diagrams Design class diagram Design ( how )
1 Another group of Patterns Architectural Patterns.
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
Chapter 17. Initial Object Design Inputs: requirements meetings various Use Cases – 10% complete Key risks addressed with preliminary programming System.
GRASP: Designing Objects With Responsibilities
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
Chapter 3 Servlet Basics. 1.Recall the Servlet Role 2.Basic Servlet Structure 3.A simple servlet that generates plain text 4.A servlet that generates.
Chapter 17 GRASP: Designing Objects with Responsibilities. 1CS6359 Fall 2011 John Cole.
Design Patterns. Patterns “Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution.
COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
GRASP: Designing Objects with Responsibilities
Architectural Patterns Support Lecture. Software Architecture l Architecture is OVERLOADED System architecture Application architecture l Architecture.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Copyright © Active Frameworks Inc. - All Rights Reserved - V2.0Design Pattern Catalog - Page L3-1 PS95&96-MEF-L10-1 Dr. M.E. Fayad Creationa.
Patterns Roberto Damiani Mendes. Roteiro Definition; Definition; Architecture Patterns; Architecture Patterns; Design Patterns; Design Patterns; GRASP.
Hints for Assignment #8. Initial Screen Hints for the initial page You need a DOCTYPE with the proper namespaces defined You need to import the facebook.
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
TK2023 Object-Oriented Software Engineering CHAPTER 8 LOGICAL ARCHITECTURE.
SEA Side – Extreme Programming 1 SEA Side Software Engineering Annotations Architectural Patterns Professor Sara Stoecklin Director of Software Engineering-
Copyright © Craig Larman All Rights Reserved COMP-350 Object-Oriented Analysis and Design GRASP: Designing Objects with Responsibilities Reference:
Chapter 17 Designing with Responsibilities. Fig
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
GRASP: More Patterns for Assigning Responsibilities Presented By Dr. Shazzad Hosain.
Elaboration: Iteration 2. Elaboration: Iteration 2 Basics Iteration 1 ends with : All the software has been tested: The idea in the UP is to do early,
GRASP – Designing Objects with Responsibilities
SOFTWARE DESIGN AND ARCHITECTURE
Conception OBJET GRASP Patterns
Apply Expert, Creator, Controller, Low Coupling, High Cohesion
GRASP : Designing Objects with Responsibilities
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
Starting Design: Logical Architecture and UML Package Diagrams
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
Chapter 8, Design Patterns Introduction
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
Presentation transcript:

SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler http://www.cs.concordia.ca/~gregb/home/soen343h-f06.html

Outline Week 9 lectures: Evaluate Good Design Page Controller and Front Controller Note Command Pattern Web EA Do-It-All TS Re-design GRASP Principles Pure Fabrication Indirection

Recall the Greeting EA A single servlet which offers the greeting “Hello”. We refactored it, offering two alternative designs.

Review Question On a blank sheet of paper … Provide three class diagrams corresponding to the three design solutions of the Greeting EA.

Evaluating a Design Which is a better design? What is a good design?

What is a good design? Satisfies user needs, requirements. Reveals intent. Is a simple as possible. Minimizes cost of … likely changes. And … High cohesion. Low coupling.

Greeting EA Evolution … What if … Support a personalized greeting. Change “look” of output (e.g. bold the name). Get full name from db.

Comparing Design Solutions Property Sol’n 1 Sol’n 2 Sol’n 3 Correct  Intent clear Simplest Acc. Change Cohesion Coupling

GRASP: Controller Who handles a system event? E.g. “List Movies” Main choices: assign to a design entity representing Overall system, or subsystem (façade controller). A Use Case scenario (often named, e.g. ListMovieHandler).

GRASP: Controller Who handles a system event? E.g. “List Movies” Main choices: assign to a design entity representing Overall system, or subsystem (façade controller). A Use Case scenario (often named, e.g. ListMovieHandler).

Presentation Domain Data Source Controller Patterns Page Controller Template View Presentation Front Controller Transform View Domain Model Transaction Script Domain Data Mapper Active Record Table Module Data Mapper Row Data Gateway Table Data Gateway Data Source Table Data Gateway

Page Controller (done)

Front Controller Fowler: A controller that handles all requests for a web site. The Front Controller consolidates all request handling by channeling requests through a single handler object. This object can carry out common behaviour which can be modified at runtime with decorators. This handler then dispatches to command objects for behaviour particular to a request.

Front Controller GoF design pattern: Command Use a Command object to encapsulate the steps that are executed by a command. Command::doIt() executes command Allows Command::unDoIt() etc GoF design pattern: Decorator Decorator::m() adds additional behaviour, but delegates to real Object::m() for real behaviour Eg, logging command execution before/after executing command

Page vs Front Controller – Differences in URL Page Controllers for A1 http:/stu.cs/343A1/ViewTaskList http:/stu.cs/343A1/AddTask http:/stu.cs/343A1/RemoveAllTasks … Front Controller for A1 Base URL: http:/stu.cs/343A1/frontController …/frontController ?command=ViewTaskList …/frontController ?command=AddTaskGrade&title=abc&…

Front Controller

Front Controller

Front Controller (Fowler) Command (GoF) Patterns FrontCommand + init ( ) + processRequest ( ) RemoveStudentCommand ViewStudInfoCommand + processRequest ( ) + processRequest ( )

Front Controller: Sequence Diagram

Front Controller: ProcessRequest

Front Controller (cont’d)

Front Controller: Advantages?

Web EA Redesign Exercise Refactoring a DoItAll Servlet, let me count the ways …

Do-it-all Servlet or Script Presentation Do-it-all Servlet or Script Domain Data Source

Do-it-all Servlet or Script, Class public class DoItAll extends javax.servlet.http.HttpServlet { protected void doGet( HttpServletRequest request, HttpServletResponse response) throws ... // … }

Redesigning This Application Redesign DoItAll so as to increase the class cohesion. Create new classes. Which EA patterns would you use? Distribute the doGet() method code (given on the next slide) into the new classes. Identify which lines would go into which classes.

Do-it-all Transaction Script, doGet() String lastName = request.getParameter(“…"); Connection dbc = DbRegistry.getDbConnection(); String findSql = "SELECT * from … where LastName = ?”; PreparedStatement dbQuery = dbc.prepareStatement(findSql); dbQuery.setString(1, lastName); ResultSet rs = dbQuery.executeQuery(); rs.next(); String firstName = rs.getString("FirstName"); lastName = lastName.toUpperCase(); PrintWriter out = response.getWriter(); response.setContentType("text/html"); out.println("<h1>Hello "+firstName+" "+lastName+"</h1>");

Do-it-all Servlet Redesign: Separating Concerns The next few slides show ways in which we can separate concerns; i.e. distribute the functionality of the do-it-all script into separate classes. Combinations other than the ones shown are possible.

Redesigning Do-it-all (2 classes) [#1] Presentation Do-it-all redesign Domain Data Source Note:

Redesigning Do-it-all (3 classes) [#3] Presentation Do-it-all redesign Domain Data Source

Redesigning Do-it-all (4 classes) [#4] Presentation Do-it-all redesign Domain Data Source

Redesigning Do-it-all : Adding … (5 classes) [#5] Presentation Do-it-all redesign Domain Data Source

Redesigning Do-it-all : Adding … [#5b] Presentation Do-it-all redesign Domain Data Source

Redesigning Do-it-all (5 classes) [#5c] Presentation Do-it-all redesign Domain Data Source Is there anything wrong with this design? (Hint: consider the dependencies and the layering style.)

Redesigning Do-it-all (6 classes) [#6] Presentation Do-it-all redesign Domain Data Source

Pure Fabrication Problem: Existing objects, ie domain objects, are not appropriate to have the responsibility Solution suggested by Information Expert not appropriate Might violate high cohesion, low coupling Solution: Fabricate (ie create, make up) a new object to hold the responsibility

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?

GRASP: Pure Fabrication Design of objects Representational decomposition Behavorial decomposition It’s OK for OO software to have objects representing behaviour, ie use case, process, function, strategy, TS But do not overdo it All GoF design patterns are Pure Fabrications

Indirection Problem: How to assign responsibility to avoid direct coupling? How to de-couple objects? Solution: Assign responsibility to an intermediatory object to mediate between the two components Example: Adapter pattern Intermediatory to external tax calculators

Fig. 25.10

Indirection “Most problems in computer science can be solved by another level of indirection”