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

Slides:



Advertisements
Similar presentations
Visibility Larman, Chapter 19 (with ideas from George Blank of NJIT) CSE432 Object Oriented Software Engineering.
Advertisements

SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
Chapter 10 THINKING IN OBJECTS 1 Object Oriented programming Instructor: Dr. Essam H. Houssein.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Satzinger, Jackson, and Burd Object-Orieneted Analysis & Design
Introduction to Data Structures, Spring 2007 Slide- 1 California State University, Fresno Introduction to Data Structure Object Oriented Programming Concepts.
March R McFadyen1 GoF (Gang of Four): Gamma, Johnson, Helm & Vlissides Book: Design Patterns: Elements of Reusable Object-Oriented Software.
ASP.NET Programming with C# and SQL Server First Edition
Design Patterns Ref : Chapter 15 Bennett et al. useful groups of collaborating classes that provide a solution to commonly occuring problems. provide.
Object Oriented Software Development
JUnit The framework. Goal of the presentation showing the design and construction of JUnit, a piece of software with proven value.
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Intro to OOP with Java, C. Thomas Wu
CSSE 374: Introduction to Gang of Four Design Patterns
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
Architectural Patterns Support Lecture. Software Architecture l Architecture is OVERLOADED System architecture Application architecture l Architecture.
Design Patterns Gang Qian Department of Computer Science University of Central Oklahoma.
CS 160: Software Engineering October 22 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
Classes. Constructor A constructor is a special method whose purpose is to construct and initialize objects. Constructor name must be the same as the.
JSP Pages. What and Why of JSP? JSP = Java code imbedded in HTML or XML –Static portion of the page is HTML –Dynamic portion is Java Easy way to develop.
CS212: Object Oriented Analysis and Design Lecture 38: Design Pattern-II.
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
Design Patterns Introduction
C++ Inheritance Data Structures & OO Development I 1 Computer Science Dept Va Tech June 2007 © McQuain Generalization versus Abstraction Abstraction:simplify.
Elaboration Iteration 3 – Part 3 - Persistence Framework -
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
1 Lecture Material Design Patterns Visitor Client-Server Factory Singleton.
Inheritance Chapter 7 Inheritance Basics Programming with Inheritance
GoF Patterns (GoF) popo.
MPCS – Advanced java Programming
Low Budget Productions, LLC
Lecture 15: More Inheritance
Object Oriented Programming using Java - Class Instance Variables
Review Session.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
CMPE212 – Stuff… Exercises 4, 5 and 6 are all fair game now.
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.
Inheritance Basics Programming with Inheritance
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
Java Programming Language
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.
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 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.
Computer Programming with JAVA
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.
CS 350 – Software Design Singleton – Chapter 21
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.
Lecture 15: Inheritance II
Design Patterns Imran Rashid CTO at ManiWeber Technologies.
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.
Final and Abstract Classes
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
Presentation transcript:

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

Agenda – Lecture 9a Review & renew. Midterm: clarifications. Looking ahead. GoF: Singleton. EA Patterns Exercises 4/17/2019 SOEN 343, © P.Chalin,

Clarifications (Walid) Constructors cannot be static. Constructors are not "inherited“ (Allen). Fields cannot be abstract. In the case of the P/C class example you can access the (non-static) field of in the parent class using the notation: super.of. The explicit call to super() is not necessary.  On the other hand, an explicit call to a super class constructor will be necessary if the default constructor of the parent is inaccessible (e.g. declared private) or if we want a constructor other than the non-default one to be invoked. 4/17/2019 SOEN 343, © P.Chalin,

Looking Ahead GRASP Gang-of-four (GoF). Enterprise Application patterns. 4/17/2019 SOEN 343, © P.Chalin,

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

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

Design Issue: Ensure No More Than One Instance of a Class is Created Given a class C, how can we ensure that only one instance of C is ever created? 4/17/2019 SOEN 343, © P.Chalin,

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

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/17/2019 SOEN 343, © P.Chalin,

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

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/17/2019 SOEN 343, © P.Chalin,

Enterprise Application Patterns (v1.3) 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 4/17/2019 SOEN 343, © P.Chalin,

Do-it-all Transaction Script Presentation Do-it-all Transaction Script Domain Data Source 4/17/2019 SOEN 343, © P.Chalin,

Do-it-all Transaction Script, Class public class DoItAllTS extends javax.servlet.http.HttpServlet { protected void doGet( HttpServletRequest request, HttpServletResponse response) throws ... // … } 4/17/2019 SOEN 343, © P.Chalin,

Redesigning This Application Redisgn DoItAllTS 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. 4/17/2019 SOEN 343, © P.Chalin,

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(); String firstName = rs.getString("FirstName"); lastName.toUpperCase(); PrintWriter out = response.getWriter(); response.setContentType("text/html"); out.println("<h1>Hello "+firstName+" "+lastName+"</h1>"); 4/17/2019 SOEN 343, © P.Chalin,

Do-it-all Transaction Script 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. 4/17/2019 SOEN 343, © P.Chalin,

Redesigning Do-it-all TS (2 classes) Presentation Do-it-all Transaction Script Page Controller (+ View) redesign Domain Table Module Data Source Note: “Page Controller (+ View)” is not an EA pattern but rather a combination of a Page Controller plus some functionality usually attributed to a view. 4/17/2019 SOEN 343, © P.Chalin,

Redesigning Do-it-all TS (2 classes) Presentation Do-it-all Transaction Script Page Controller (+ View) redesign Domain Active Record Data Source 4/17/2019 SOEN 343, © P.Chalin,

Redesigning Do-it-all TS (3 classes) Presentation Do-it-all Transaction Script Page Controller (+ View) redesign Transaction Script Domain Gateway Data Source G, a Gateway, can be either a TDG or an RDG 4/17/2019 SOEN 343, © P.Chalin,

Redesigning Do-it-all TS (4 classes) Presentation Do-it-all Transaction Script Page Controller Template View redesign Transaction Script Domain Gateway Data Source 4/17/2019 SOEN 343, © P.Chalin,

Redesigning Do-it-all TS (4 classes) Presentation Do-it-all Transaction Script Page Controller Template View redesign Person Mapper Person Domain [Pull out this slide in Fall 05] DbRegistry Data Source Since I added some domain logic to the sample code, this solution is no longer valid. 4/17/2019 SOEN 343, © P.Chalin,

Redesigning Do-it-all TS (5 classes) Presentation Do-it-all Transaction Script Page Controller Template View redesign Transaction Script Person Domain Person Mapper Data Source Is there anything wrong with this design? (Hint: consider the dependencies and the layering style.) 4/17/2019 SOEN 343, © P.Chalin,

Redesigning Do-it-all TS (6 classes) Presentation Do-it-all Transaction Script Page Controller Template View redesign Transaction Script Person Domain Person Mapper Table Data Gateway Data Source 4/17/2019 SOEN 343, © P.Chalin,

Presentation Domain Data Source EA Patterns Page Controller Template View Presentation Front Controller Transform View Domain Model Transaction Script Domain Active Record Table Module Data Mapper Row Data Gateway Table Data Gateway Data Source 4/17/2019 SOEN 343, © P.Chalin,

Data Source Patterns Active Record is a Row Data Gateway + domain logic. Table Module is a Table Data Gateway + domain logic. Data Mapper maps Domain Model’s <---> database: Can either access the database itself, or Makes use of a Table Data Gateway. Does not contain Domain Logic (though it can be in the Domain Logic layer). 4/17/2019 SOEN 343, © P.Chalin,

Data Mapper Example (Tasks) 4/17/2019 SOEN 343, © P.Chalin,

Exercise Set 8 Answer Exercise Set 8 as you work through assignment 1 4/17/2019 SOEN 343, © P.Chalin,

Exercise Set 9 Setup: sit with your teammates. Part I – do this on your own For each of the design solutions, fill in the grey boxes (representing classes in a class diagram) with a class name and/or pattern name. Part II – each member of the team chooses one of the design solutions and writes (a) A detailed class diagram for the solution. (b) The code for the solution. 4/17/2019 SOEN 343, © P.Chalin,