CSE 240 Lecture 9. © Lethbridge/Laganière 2001 Chapter 5: Modelling with classes2 Overview Chapter 6 Start on Chapter 7 if time permits.

Slides:



Advertisements
Similar presentations
Comp1004: Object Oriented Design II Designing Applications Based on BlueJ Chapter 13.
Advertisements

Chapter 6: Using Design Patterns
© Lethbridge/Laganière 2001 Chapter 9: Architecting and designing software1 Layers Data from IBM-Rational and Craig Larman…
Chapter 8: Modelling Interactions and Behaviour
March R McFadyen1 GoF (Gang of Four): Gamma, Johnson, Helm & Vlissides Book: Design Patterns: Elements of Reusable Object-Oriented Software.
Design Patterns – Part 3 Sources:
Object-Oriented Software Engineering Practical Software Development using UML and Java Design Patterns Sources: Chapter 6: Using Design Patterns, and Chapter.
© Lethbridge/Laganière 2001 Chapter 7: Focusing on Users and Their Tasks1 7.1 User Centred Design (UCD) Software development should focus on the needs.
Chapter 6: Using Design Patterns
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 6: Using Design Patterns.
Winter 2007ACS-3913 Ron McFadyen1 Singleton To guarantee that there is at most one instance of a class we can apply the singleton pattern. Singleton Static.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
Programming With Java ICS201 University Of Hail1 Chapter 12 UML and Patterns.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 6: Using Design Patterns Part 1.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 8: Modelling Interactions and Behaviour.
Draw a small class diagram (2 or 3 classes) for each of the following examples: For Netflixs, you have to keep track of the movie details AND the copies.
9/18/2015CPSC , CPSC , Lecture 81 Software Engineering, CPSC , CPSC , Lecture 8.
Design patterns. What is a design pattern? Christopher Alexander: «The pattern describes a problem which again and again occurs in the work, as well as.
Chapter 1 Object-Oriented Analysis and Design. Disclaimer Slides come from a variety of sources: –Craig Larman-developed slides; author of this classic.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Chapter 4: Developing Requirements
Design Patterns – Details Part 2 Gang of Four (GoF) Patterns GRASP Patterns More Sources: Chapter 6: Using Design Patterns, and Chapter 30 (parts) Designing.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 6: Using Design Patterns 1.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 7: Focusing on Users and Their Tasks.
Advanced Programming Rabie A. Ramadan 7.
Objects First With Java A Practical Introduction Using BlueJ Designing applications 1.0.
CSE 240 Lecture 10. © Lethbridge/Laganière 2001 Chapter 7: Focusing on Users and Their Tasks2 For Next time Finish Reading Chapter 6 Read Chapter 7.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 4: Developing Requirements.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Chapter 1 Object-Oriented Analysis and Design. Disclaimer Slides come from a variety of sources: –Craig Larman-developed slides; author of this classic.
Object-Oriented Analysis and Design Fall 2009.
03/12/2001 © Bennett, McRobb and Farmer 2002 Refining the Requirements Model Based on Chapter 8 of Bennett, McRobb and Farmer: Object Oriented Systems.
DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 6: Using Design Patterns.
CSE 432: Design Patterns Introduction What’s a Pattern? What’s an Idiom? According to Alexander, a pattern: –Describes a recurring problem –Describes the.
Patterns COM379 University of Sunderland James Malone.
Singleton and Basic UML CS340100, NTHU Yoshi. What is UML Unified Modeling Language A standardized general-purpose modeling language in the field of software.
Reformatted slides from the textbook, C++ How to Program, 6/e Pearson Education, Inc. All rights reserved Chapter 3. [Lecture 02] Introduction to.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 4: Developing Requirements.
Design Principle & Patterns by A.Surasit Samaisut Copyrights : All Rights Reserved.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 8: Modelling Interactions and Behaviour UML Sequence Diagram.
Introduction to Design Patterns Part 1. © Lethbridge/Laganière 2001 Chapter 6: Using design patterns2 Patterns - Architectural Architectural Patterns:
Designing applications Main concepts to be covered Discovering classes CRC cards Designing interfaces Patterns Objects First with Java - A Practical.
CS0007: Introduction to Computer Programming Classes: Documentation, Method Overloading, Scope, Packages, and “Finding the Classes”
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
Csci 490 / Engr 596 Special Topics / Special Projects Software Design and Scala Programming Spring Semester 2010 Lecture Notes.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 6: Using Design Patterns.
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
1 Chapter 5:Design Patterns. 2 What are design pattern?  Schematic description of design solution to recurring problems in software design and,  Reusable.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 7: Focusing on Users and Their Tasks.
CSCE 240 – Intro to Software Engineering Lecture 2.
Engr 691 Special Topics in Engineering Science Software Architecture Spring Semester 2004 Lecture Notes.
MECHATRONICS Group # Group Members’ Names MENG 483 Project Title of the Project Spring 20XX.
CSCE 240 – Intro to Software Engineering Lecture 3.
Subtopics: 1. Frameworks :Reusable systems 2. Design Patterns 1.
1 M206 Chapter 31: An Overview of Software Development 1.Defining the problem 2.Analyzing the requirement – constructing initial structural model 3.Analyzing.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 6: Using Design Patterns.
Introduction to Generic Programming in C++
Design Patterns (Chapter 6 of Text Book – Study just 8)
Chapter 6: Using Design Patterns
Chapter 5:Design Patterns
Chapter 6: Using Design Patterns
Chapter 1 Object-Oriented Analysis and Design. Disclaimer Slides come from a variety of sources: –Craig Larman-developed slides; author of this classic.
PH page GoF Singleton p Emanuel Ekstrom.
Introduction to Design Patterns Part 1
CS 350 – Software Design Singleton – Chapter 21
Design Patterns Imran Rashid CTO at ManiWeber Technologies.
Presentation transcript:

CSE 240 Lecture 9

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes2 Overview Chapter 6 Start on Chapter 7 if time permits

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes3 For Next time Finish Reading Chapter 6 Read Chapter 7

Quote of the day “Any sufficiently advanced technology is indistinguishable from magic.” Arthur C. Clarke ( ) “Technology and the Future"

Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 6: Using Design Patterns (authors slides)

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes6 6.1 Introduction to Patterns The recurring aspects of designs are called design patterns. A pattern is the outline of a reusable solution to a general problem encountered in a particular context Many of them have been systematically documented for all software developers to use A good pattern should —Be as general as possible —Contain a solution that has been proven to effectively solve the problem in the indicated context. Studying patterns is an effective way to learn from the experience of others

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes7 Pattern description Context: The general situation in which the pattern applies Problem: —A short sentence or two raising the main difficulty. Forces: The issues or concerns to consider when solving the problem Solution: The recommended way to solve the problem in the given context. —‘to balance the forces’ Antipatterns: (Optional) Solutions that are inferior or do not work in this context. Related patterns: (Optional) Patterns that are similar to this pattern. References: Who developed or inspired the pattern.

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes8 6.2 The Abstraction-Occurrence Pattern Context: —Often in a domain model you find a set of related objects (occurrences). —The members of such a set share common information -but also differ from each other in important ways. Problem: —What is the best way to represent such sets of occurrences in a class diagram? Forces: —You want to represent the members of each set of occurrences without duplicating the common information

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes9 Abstraction-Occurrence Solution: TVSeries seriesName producer Episode number title storySynopsis ****** «Occurrence»«Abstraction» ****** Title name author LibraryItem barCodeNumber ****** isbn publicationDate libOfCongress

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes10 Abstraction-Occurrence Antipatterns:

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes The General Hierarchy Pattern Context: —Objects in a hierarchy can have one or more objects above them (superiors), -and one or more objects below them (subordinates). —Some objects cannot have any subordinates Problem: —How do you represent a hierarchy of objects, in which some objects cannot have subordinates? Forces: —You want a flexible way of representing the hierarchy -that prevents certain objects from having subordinates —All the objects have many common properties and operations

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes12 General Hierarchy Solution: «subordinate» * «Node» «SuperiorNode»«NonSuperiorNode» * supervises Manager Employee TechnicianSecretary 0..1 * contains Directory FileSystemItem File 0..1

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes13 General Hierarchy Antipattern: RockRecordingBluesRecordingClassicalRecordingJazzRecordingMusicVideoVideoRecodingAudioRecordingRecording

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes The Singleton Pattern Context: —It is very common to find classes for which only one instance should exist (singleton) Problem: —How do you ensure that it is never possible to create more than one instance of a singleton class? Forces: —The use of a public constructor cannot guarantee that no more than one instance will be created. —The singleton instance must also be accessible to all classes that require it

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes15 Singleton Solution: Company theCompany Company «private» getInstance if (theCompany==null) theCompany= new Company(); return theCompany; «Singleton» theInstance getInstance

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes Difficulties and Risks When Creating Class Diagrams Patterns are not a panacea: —Whenever you see an indication that a pattern should be applied, you might be tempted to blindly apply the pattern. However this can lead to unwise design decisions. Resolution: — Always understand in depth the forces that need to be balanced, and when other patterns better balance the forces. —Make sure you justify each design decision carefully.

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes17 Difficulties and Risks When Creating Class Diagrams Developing patterns is hard —Writing a good pattern takes considerable work. —A poor pattern can be hard to apply correctly Resolution: —Do not write patterns for others to use until you have considerable experience both in software design and in the use of patterns. —Take an in-depth course on patterns. —Iteratively refine your patterns, and have them peer reviewed at each iteration.