Chapter Five An Introduction to Design Patterns Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information.

Slides:



Advertisements
Similar presentations
GRASP: Designing Objects with Responsibilities
Advertisements

Ch 3 System Development Environment
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.
Design Patterns Examples of smart use of inheritance and polymorphism: Composite Pattern State Pattern FEN 2014UCN Teknologi/act2learn1.
Object-Oriented Design Patterns Composite Singleton State Observer … Autumn 2012UCN Technology: IT/Computer Science1.
Chapter 8, Object Design Introduction to Design Patterns
Introduction to Design Patterns (1). “ In software engineering, a design pattern is a general reusable solution to a commonly occurring problem in software.
Ralph Johnson - University of Illinois1 Patterns: What They Are, and How to Write Them Ralph Johnson University of Illinois at Urbana-Champaign
Chapter 8 Object Design Reuse and Patterns. Finding Objects The hardest problems in object-oriented system development are: –Identifying objects –Decomposing.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.
Chapter 22 Object-Oriented 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.
Chapter 1 The Systems Development Environment
Introduction to software design patterns For CSE 3902 By: Matt Boggus.
Design Patterns Discussion of pages: xi-11 Sections: Preface, Forward, Chapter
Design Patterns Trends and Case Study John Hurst June 2005.
Chapter 7 GRASP patterns Dr Seham Mostefai CAP 252.
Session 05: C# Patterns Algorithm Patterns: Sweep Search FEN AK IT: Softwarekonstruktion.
Introduction to Design Patterns (1). Definition: “ In software engineering, a design pattern is a general reusable solution to a commonly occurring problem.
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 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.
101 User Interface Patterns and its applications Tonya Groover Department of Computer Science.
January 12, Introduction to Design Patterns Tim Burke References: –Gamma, Erich, et. al. (AKA, The Gang of Four). Design Patterns: Elements of Reusable.
CSC 211 Introduction to Design Patterns. Intro to the course Syllabus About the textbook – Read the introduction and Chapter 1 Good attendance is the.
Design Patterns in Education Josh Steele Matt Aguirre April 8, 2002.
ANU COMP2110 Software Design in 2004 Lecture 15Slide 1 COMP2110 in 2004 Software Design Lecture 15: Software design patterns (2) 1What are design patterns?
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 27. Review UML dynamic view – State Diagrams.
A Reference Model for Event Patterns Christian Silberbauer
Object-Oriented Design Principles and Patterns. © 2005, James R. Vallino2 How Do You Design? What principles guide you when you create a design? What.
GRASP: Designing Objects with Responsibilities
Chapter 3 Object Oriented Systems and Open GIS. Objectives of the Chapter Establish place of O-O in OpenGIS cover basics of O-O emphasise design issues.
How Would You Solve This? l Suppose that you want to have one and only one instance of a class – Can you think of ever only wanting one instance of a class?
Introduction to Design Patterns Part 1. © Lethbridge/Laganière 2001 Chapter 6: Using design patterns2 Patterns - Architectural Architectural Patterns:
Chapter 18 The Observer Pattern Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh.
Object Orientation Concepts, Terminology and a Story. © Allan C. Milne School of Engineering, Computing & Applied Mathematics University of Abertay v
Chapter 21 Design Patterns Reviewed from the New Perspective of Object-Oriented Design Ku-Yaw Chang Assistant Professor, Department.
Design Patterns: Elements of Reusable Object- Orientated Software Gamma, Helm, Johnson, Vlissides Presented By: David Williams.
More Design Patterns From: Shalloway & Trott, Design Patterns Explained, 2 nd ed.
Design Patterns in Context ©SoftMoore ConsultingSlide 1.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Chapter Eight Expanding Our Horizons Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering.
Chapter Ten The Bridge Pattern Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh.
From the customer’s perspective the SRS is: How smart people are going to solve the problem that was stated in the System Spec. A “contract”, more or less.
Chapter 2 Principles of Programming and Software Engineering.
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.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
GRASP – Designing Objects with Responsibilities
Design Patterns: MORE Examples
How Would You Solve This?
The Object-Oriented Thought Process Chapter 15
Chapter Six The Facade Pattern
Introduction to Design Patterns
Chapter Nine The Strategy Pattern
Design Patterns Introduction
CMPE 135: Object-Oriented Analysis and Design October 24 Class Meeting
Introduction to Design Patterns Part 1
Patterns.
Object oriented analysis and design
DESIGNING YOUR SYSTEM.
CS 350 – Software Design An Introduction to Design Patterns – Chapter 5 A proposition behind design patterns is that quality of software systems can be.
DESIGN PATTERNS : Introduction
Lecture taken from “Design Patterns Explained” by Addison Wesley
CMPE 135 Object-Oriented Analysis and Design March 21 Class Meeting
Chapter 8, Design Patterns Introduction
Software Design Lecture : 27.
Presentation transcript:

Chapter Five An Introduction to Design Patterns Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University

2Ku-Yaw ChangThe Object-Oriented Paradigm Outline Overview Design Patterns Arose from Architecture and Anthropology Moving from Architectural to Software Design Patterns Why Study Design Patterns? Other Advantages to Studying Design Patterns Summary

3Ku-Yaw ChangThe Object-Oriented Paradigm Overview Design patterns Cutting edge of the OO technology Cutting edge of the OO technologyRelationships Master OO skills first, then learn design patterns Master OO skills first, then learn design patterns The opposite is also true The opposite is also true Learning design patterns early in the learning of object- oriented skills greatly helps to improve understanding of object-oriented analysis and design. Design patterns and OO design reinforce each other Design patterns and OO design reinforce each other Many ideas are from Christopher Alexander’s Timeless Way of Building Christopher Alexander’s Timeless Way of Building

4Ku-Yaw ChangThe Object-Oriented Paradigm Outline Overview Design Patterns Arose from Architecture and Anthropology Moving from Architectural to Software Design Patterns Why Study Design Patterns? Other Advantages to Studying Design Patterns Summary

5Ku-Yaw ChangThe Object-Oriented Paradigm Design Patterns Arose from Architecture and Anthropology Christopher Alexander asked himself Is quality objective? Is quality objective? What makes us know when an architectural design is good? What makes us know when an architectural design is good? Alexander postulates There is such an objective basis within architectural systems. There is such an objective basis within architectural systems. We can describe beauty through an objective basis that can be measured. We can describe beauty through an objective basis that can be measured.

6Ku-Yaw ChangThe Object-Oriented Paradigm Design Patterns Arose from Architecture and Anthropology If quality in design is objective Be able to identify what makes designs good and what makes designs bad Be able to identify what makes designs good and what makes designs bad Alexander asked What is present in a good quality design that is not present in a poor quality design? What is present in a good quality design that is not present in a poor quality design? What is present in a poor quality design that is not present in a good quality design? What is present in a poor quality design that is not present in a good quality design? Alexander discovered Good constructs had things in common with each other Good constructs had things in common with each other

7Ku-Yaw ChangThe Object-Oriented Paradigm Design Patterns Arose from Architecture and Anthropology Two porches may appear structurally different appear structurally different solve the same (or similar) problem solve the same (or similar) problem be considered high quality be considered high quality

8Ku-Yaw ChangThe Object-Oriented Paradigm Design Patterns Arose from Architecture and Anthropology Alexander narrowed his focus Look at structures that solve similar problems Look at structures that solve similar problems Discern similarities between designs that were high quality Discern similarities between designs that were high quality These similarities are called patterns These similarities are called patterns A solution to a problem in a context Each pattern describes a problem which occurs over and over again in our environment and then describes the core of the solution to the problem, in such a way that you can reuse this solution a million times over, without ever doing it the same way twice. Each pattern describes a problem which occurs over and over again in our environment and then describes the core of the solution to the problem, in such a way that you can reuse this solution a million times over, without ever doing it the same way twice.

9Ku-Yaw ChangThe Object-Oriented Paradigm Design Patterns Arose from Architecture and Anthropology Four essential items The name of the pattern The name of the pattern The purpose of the pattern, the problem it solves The purpose of the pattern, the problem it solves How we could accomplish this How we could accomplish this The constraints and forces we have to consider in order to accomplish it The constraints and forces we have to consider in order to accomplish it Alexander postulated Patterns can solve virtually every architectural problem that one will encounter Patterns can solve virtually every architectural problem that one will encounter Patterns could be used together to solve complex architectural problems Patterns could be used together to solve complex architectural problems

10Ku-Yaw ChangThe Object-Oriented Paradigm Outline Overview Design Patterns Arose from Architecture and Anthropology Moving from Architectural to Software Design Patterns Why Study Design Patterns? Other Advantages to Studying Design Patterns Summary

11Ku-Yaw ChangThe Object-Oriented Paradigm Moving from Architectural to Software Design Patterns In the early 1990s, some smart developers Happened upon Alexander’s work in patterns Happened upon Alexander’s work in patterns Wondered if what was true for architectural patterns would also be true for software design? Wondered if what was true for architectural patterns would also be true for software design? Were there problems in software that occur over and over again that could be solved somewhat the same manner? Was it possible to design software in terms of patterns, creating specific solutions based on these patterns only after the patterns had been identified? The answer to both of the above questions are “unequivocally yes.” The answer to both of the above questions are “unequivocally yes.”

12Ku-Yaw ChangThe Object-Oriented Paradigm Moving from Architectural to Software Design Patterns Early work on design patterns Design Patterns: Elements of Reusable Object- Oriented Software by GoF Design Patterns: Elements of Reusable Object- Oriented Software by GoF Identified the patterns ( not create the patterns ) Served the following purposes Served the following purposes It applied the idea of design patterns to software design. It described a structure within which to catalog and describe design patterns. It cataloged 23 such patterns. It postulated object-oriented strategies and approaches based on these design patterns.

13Ku-Yaw ChangThe Object-Oriented Paradigm Key Features of Patterns

14Ku-Yaw ChangThe Object-Oriented Paradigm Outline Overview Design Patterns Arose from Architecture and Anthropology Moving from Architectural to Software Design Patterns Why Study Design Patterns? Other Advantages to Studying Design Patterns Summary

15Ku-Yaw ChangThe Object-Oriented Paradigm Why Study Design Patterns? Reuse solutions Not have to reinvent solutions for commonly recurring problems Not have to reinvent solutions for commonly recurring problems Establish common terminology A common base of vocabulary A common base of vocabulary A common viewpoint of the problem A common viewpoint of the problem Give a higher-level perspective On the problem On the problem On the process of design and object orientation On the process of design and object orientation

16Ku-Yaw ChangThe Object-Oriented Paradigm Why Study Design Patterns? A conversation between two carpenters Carpenter 1: How do you think we should build these drawers? Carpenter 1: How do you think we should build these drawers? Carpenter 2: Well, I think we should make the joint by cutting straight down into the wood, and then cut back up 45 degrees, and the going straight back down, and then back up the other way 45 degree, and the going straight back down, and then … Carpenter 2: Well, I think we should make the joint by cutting straight down into the wood, and then cut back up 45 degrees, and the going straight back down, and then back up the other way 45 degree, and the going straight back down, and then … The details may confuse the solution.

17Ku-Yaw ChangThe Object-Oriented Paradigm Why Study Design Patterns?

18Ku-Yaw ChangThe Object-Oriented Paradigm Why Study Design Patterns? Carpenter 1: Should we use a dovetail joint or a miter joint? A miter joint A miter joint It is a simpler solution. It is lightweight. It is inconspicuous. A dovetail joint A dovetail joint It is a more complex solution. It is impervious to temperature and humidity. It is independent of the fastening system. It is a more aesthetically pleasing joint.

19Ku-Yaw ChangThe Object-Oriented Paradigm Why Study Design Patterns? Carpenter 1 Should we use a dovetail joint or a miter joint? Should we use a dovetail joint or a miter joint? The real question is The real question is Should we use a joint that is expensive to make but is both beautiful and durable, or should we just make a quick and dirty joint that will last at least as long until the check clears? Should we use a joint that is expensive to make but is both beautiful and durable, or should we just make a quick and dirty joint that will last at least as long until the check clears? Which is more efficient? Who would you rather work with? Patterns help raise the level of your thinking See the forest and the trees See the forest and the trees

20Ku-Yaw ChangThe Object-Oriented Paradigm Outline Overview Design Patterns Arose from Architecture and Anthropology Moving from Architectural to Software Design Patterns Why Study Design Patterns? Other Advantages to Studying Design Patterns Summary

21Ku-Yaw ChangThe Object-Oriented Paradigm Other Advantages to Studying Design Patterns Experiences from the Author Help both individual learning and team development Help both individual learning and team development Improve modifiability of code Improve modifiability of code Illustrate basic object-oriented principles Illustrate basic object-oriented principles Strategies from GoF Design to Interface Design to Interface Favor composition over inheritance Favor composition over inheritance Find what varies and encapsulate it Find what varies and encapsulate it

22Ku-Yaw ChangThe Object-Oriented Paradigm Outline Overview Design Patterns Arose from Architecture and Anthropology Moving from Architectural to Software Design Patterns Why Study Design Patterns? Other Advantages to Studying Design Patterns Summary

23Ku-Yaw ChangThe Object-Oriented Paradigm Summary Reasons for studying design patterns Reuse existing, high-quality solutions to commonly recurring problems. Reuse existing, high-quality solutions to commonly recurring problems. Establish common terminology to improve communications within teams. Establish common terminology to improve communications within teams. Shift the level of thinking to a higher perspective. Shift the level of thinking to a higher perspective. Decide whether I have the right design, not just one that works. Decide whether I have the right design, not just one that works.

24Ku-Yaw ChangThe Object-Oriented Paradigm Summary (cont.) Improve individual learning and team learning. Improve individual learning and team learning. Improve the modifiability of code. Improve the modifiability of code. Facilitate adoption of improved design alternatives, even when patterns are not used explicitly. Facilitate adoption of improved design alternatives, even when patterns are not used explicitly. Discover alternatives to large inheritance hierarchies. Discover alternatives to large inheritance hierarchies.

The End