Comp2110 Software Design lecture 13Detailed Design (1)  detailed design contrasted with high level design  introducing the Observer Design Pattern 

Slides:



Advertisements
Similar presentations
Software Development Languages and Environments. Programming languages High level languages are problem orientated contain many English words are easier.
Advertisements

Observer Method 1. References Gamma Erich, Helm Richard, “Design Patterns: Elements of Reusable Object- Oriented Software” 2.
ANU COMP2110 Software Design in 2003 Lecture 16Slide 1 Lecture 16: Introduction to design patterns 1What are they? 2Where do they come from? 3Why study.
Chapter 1 - An Introduction to Computers and Problem Solving
OOP Design Patterns Chapters Design Patterns The main idea behind design patterns is to extract the high level interactions between objects and.
C++ Training Datascope Lawrence D’Antonio Lecture 12 Design Patterns.
© Copyright 2011 John Wiley & Sons, Inc.
Observer Pattern Fall 2005 OOPD John Anthony. What is a Pattern? “Each pattern describes a problem which occurs over and over again in our environment,
Software Reuse Building software from reusable components Objectives
CS350/550 Software Engineering Lecture 1. Class Work The main part of the class is a practical software engineering project, in teams of 3-5 people There.
Software Engineering I Object-Oriented Design Software Design Refinement Using Design Patterns Instructor: Dr. Hany H. Ammar Dept. of Computer Science.
Chapter 8 Object Design Reuse and Patterns. Finding Objects The hardest problems in object-oriented system development are: –Identifying objects –Decomposing.
Chapter 1 Program Design
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
MVC pattern and implementation in java
Design Patterns.
Session 05: C# Patterns Algorithm Patterns: Sweep Search FEN AK IT: Softwarekonstruktion.
Design Patterns OOD. Course topics Design Principles UML –Class Diagrams –Sequence Diagrams Design Patterns C#,.NET (all the course examples) Design Principles.
1/19 Component Design On-demand Learning Series Software Engineering of Web Application - Principles of Good Component Design Hunan University, Software.
Prologue: The Software Process. Main Phases of Software Process 1. Requirements Analysis (answers “WHAT?”) Specifying what the application must do 2.
Chapter 5 Design Principles II: Flexibility, Reusability, and Efficiency.
Lecture # 06 Design Principles II
Software Design Refinement Using Design Patterns Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Objectives Lecture 11 : Frameworks SWE 316: Software Design and Architecture  To understand.
Chapter 5 Design Principles II: Flexibility, Reusability, and Efficiency.
An Introduction to Software Architecture
CSE 303 – Software Design and Architecture
CS 350 – Software Design An Introduction to Design Patterns – Chapter 5 A proposition behind design patterns is that quality of software systems can be.
Chapter Five An Introduction to Design Patterns Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Putting together a complete system Chapter 10. Overview  Design a modest but complete system  A collection of objects work together to solve a problem.
ANU COMP2110 Software Design in 2004 Lecture 15Slide 1 COMP2110 in 2004 Software Design Lecture 15: Software design patterns (2) 1What are design patterns?
Creational Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Patterns in programming 1. What are patterns? “A design pattern is a general, reusable solution to a commonly occurring problem in software. A design.
Odyssey A Reuse Environment based on Domain Models Prepared By: Mahmud Gabareen Eliad Cohen.
Patterns and Reuse. Patterns Reuse of Analysis and Design.
Object-Oriented Design Principles and Patterns. © 2005, James R. Vallino2 How Do You Design? What principles guide you when you create a design? What.
CS 350 – Software Design The Observer Pattern – Chapter 18 Let’s expand the case study to include new features: Sending a welcome letter to new customers.
GoF Sections Design Problems and Design Patterns.
Chapter 8 Object Design Reuse and Patterns. Object Design Object design is the process of adding details to the requirements analysis and making implementation.
Introduction to Design Patterns Part 1. © Lethbridge/Laganière 2001 Chapter 6: Using design patterns2 Patterns - Architectural Architectural Patterns:
SOFTWARE DESIGN. INTRODUCTION There are 3 distinct types of activities in design 1.External design 2.Architectural design 3.Detailed design Architectural.
CSC 480 Software Engineering Design With Patterns.
Design Pattern. Definition: A design pattern is a general reusable solution to a commonly occurring problem within a given context in software design.
© 2010 John Wiley & Sons Ltd. Software Engineering Modern Approaches Eric Braude and Michael Bernstein 1.
ANU comp2110 Software Design lecture 8 COMP2110 Software Design in 2004 lecture 8 Software Architecture 1 of 2 (design, lecture 3 of 6) Goal of this small.
1 CSE 331 Model/View Separation and Observer Pattern slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia.
Review of Parnas’ Criteria for Decomposing Systems into Modules Zheng Wang, Yuan Zhang Michigan State University 04/19/2002.
COMP2110 Software Design in 2003 ● a(nother) framework for Software Engineering ● the Software Engineering ideas and concepts in comp2110 ● Organisation.
ANU comp2110 Software Design lecture 10 COMP2110 Software Design in 2004 lecture 10 Software Architecture 2 of 2 design lecture 5 of 6 Goal of this small.
From Use Cases to Implementation 1. Structural and Behavioral Aspects of Collaborations  Two aspects of Collaborations Structural – specifies the static.
Duke CPS Programming Heuristics l Identify the aspects of your application that vary and separate them from what stays the same ä Take what varies.
Class Relationships Lecture Oo08 Polymorphism. References n Booch, et al, The Unified Modeling Language User Guide, Chapt 10 p.125 n Fowler & Scott, UML.
1 Good Object-Oriented Design Dr. Radu Marinescu Lecture 4 Introduction to Design Patterns.
The Observer Design Pattern Author :Erich Gamma, et al. Source :Elements of Reusable Object-Oriented Software Speaker : Chiao-Ping Chang Advisor : Ku-Yaw.
From Use Cases to Implementation 1. Mapping Requirements Directly to Design and Code  For many, if not most, of our requirements it is relatively easy.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
Design Patterns: MORE Examples
Software Design Refinement Using Design Patterns
COMP2110 Software Design in lecture 14 Patterns(1) /Detailed Design
The Object-Oriented Thought Process Chapter 15
CMPE 135: Object-Oriented Analysis and Design October 24 Class Meeting
Instructor: Dr. Hany H. Ammar
Web Programming Language
Patterns.
CS 350 – Software Design An Introduction to Design Patterns – Chapter 5 A proposition behind design patterns is that quality of software systems can be.
An Introduction to Software Architecture
CMPE 135 Object-Oriented Analysis and Design March 21 Class Meeting
CSC 480 Software Engineering
Presentation transcript:

comp2110 Software Design lecture 13Detailed Design (1)  detailed design contrasted with high level design  introducing the Observer Design Pattern  information resources: o lecture and Tetris design lecture from notes.html o Braude Software Design o chapters 4 & 5 – background o chapter 6: Design Patterns o chapter 9: Observer No lectures next 2 weeks (weeks 8 & 9) gives time for your presentations in lab class times

Process Phase for this module Requirements Analysis Design Implementation ArchitectureFrameworkDetailed Design Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

Recap from lecture 6: Design (1) Module structure One way to describe the program's module structure is called a "module guide" o defines the name for each module and the design responsibility for a module by stating the design decisions/ areas of design responsibility that will be found within it ( not the functional responsibility) o This is a decomposition of the solution o decompose the solution into modules, each module may consist of submodules o the document should reflect a tree structure, dividing the system into a small number of modules and treating each module in the same way until all modules are "quite small" Note: o we also call this the system architecture or high-level design o there are other ways to choose and describe the architecture

Design (1) Module structure/architecture Architecture: ● The system is event driven in a computational loop that generates and drives a series of falling bricks in soft real time, using interrupt events to process user command keystrokes. The system includes a reusable generic playing field for games with coloured tiles. The system design requires a generic GUI library.

Module relationships uses relationships... between modules...between classes

Class relationships and interfaces

Class relationships – control sequence

Key Concept:  Flexibility  We design flexibly, introducing parts, because change and reuse are likely. Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

Making a Method Re-usable  Specify completely o Preconditions etc (see Braude section 1.2.2)  Avoid unnecessary coupling with the enclosing class 1. Make static if feasible 2. Include parameterization 1. i.e., make the method functional 2. But limit the number of parameters  Make the names expressive Understandability promotes re-usability Explain the algorithm Re-users need to know how the algorithm works Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

Making a Class Re-usable  Describe the class completely  Make the class name and functionality match a real world concept 1. Define a useful abstraction o attain broad applicability 2. Reduce dependencies on other classes Elevate dependencies in the hierarchy alternatives Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

Example: design of a Command Line Calculator- requirements 1. CommandLineCalculator begins by asking the user how many accounts he wants to open. It then establishes the desired number, each with zero balance. 2. CommandLineCalculator asks the user which of these accounts he wants to deal with. 3. When the user has selected an account, CommandLineCalculator allows the user to add whole numbers of dollars to, or subtract them from the account for as long as he requires. 4. When the user is done with an account, he is permitted to quit, or to pick another account to process. Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission. (from chapter 1.4.1)

A More Flexible Design for Calculator Application CommandLineCalculator main() executeAdditions() solicitNumberAccounts() getAnInputFromUser() interactWithUser() Existing Design New Design Calculator solicitNumAccounts() CalcDisplay display() CalcOperation execute() AddMultiplyDivide Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

Two kinds of reuse  actual software (packages, classes) can be reused if designed well o but it is difficult to do design this well  existing ideas, concepts, general ways of putting components together can be adapted by the designer to new projects o Design Patterns are an excellent of describing sets of well-known ideas for designers to reuse

Design Patterns  Design Patterns have names: other designers can recognise what you are doing and playing variations on  Design Patterns have documented properties: where and how they work, what performance problems, what other restrictions  Design patterns can save lots of time learning by (bad) experience: pre-packaged (good) experiences  thinking in design patterns pushes us to think generally, more abstractly, more productively

The point of studying design patterns  Enable you to re-use great design ideas  Create a common vocabulary for talking about design with designers, reviewers, programmers.  Give you a higher-level perspective on design, o allow you to talk and think at a higher level of abstraction (Forest vs. trees)  The solutions in the standard patterns embody some important design principles o in particular many of them produce code that is much easier to modify than a more straightforward, simple-minded solution.

Patterns: from their inventor, a bricks-and-mortar Architect Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice. Christopher Alexander

Describing Software Design Patterns ItemDescription NameA unique name that identifies this pattern IntentThe purpose of this pattern Problem The problem the pattern tries to solve Solution How the pattern provides a solution to the problem Participant and Collaborators The entities (usually classes) involved in the pattern Consequences The consequences of using this pattern; discussion of the forces at play Implementation How to implement it GoF Page number in the Gang of Four book (Gamma et al)

Observer pattern  see also Braude 9.5 Problem: Changes to one object require changes to others that depend on it, but you don't know how many objects will need to be changed. Examples:  a networked file system  a spreadsheet program with charts and graphs  a set of different views (render, edit, window) over a single complex structured text-like file (e.g. HTML)

Observer (1) Here is the "standard" pattern outline [GoF pp ]  NameObserver  IntentDefine a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.  ProblemYou need to notify a varying list of objects that an event has occurred.  SolutionThe observers delegate the responsibility for monitoring for an event to a central object: the subject (or Source- Braude)

Observer (2)  Participants and CollaboratorsThe subject knows its observers because they register with it. The subject must notify the observers when the event occurs. The observers are responsible both for registering with the subject and for getting the information they need from the subject when notified.  ConsequencesSubjects may tell observers about events they do not need to know about, if some observers are only interested in a subset of events. Extra communication is needed when the observers ask the subject for more information.

Observer (3)  ImplementationHave observers register with the subject. The subject is responsible for monitoring for (or generating) the interesting events. Observers need to keep a reference to the subject. The subject needs to keep a list of observers and to add observers or remove them from the list on request. When an interesting event occurs, the subject goes through its list and tells each observer to update itself.