Dept. of Computer Engineering, Amirkabir University of Tech. 1 Design Patterns Dr. Noorhosseini Introduction.

Slides:



Advertisements
Similar presentations
Design Patterns.
Advertisements

Welcome to. Who am I? A better way to code Design Patterns ???  What are design patterns?  How many are there?  How do I use them?  When do I use.
Lecture 9 Design Patterns CSCI – 3350 Software Engineering II Fall 2014 Bill Pine.
18-1 Verifying Object Behavior and Collaboration Role playing – the act of simulating object behavior and collaboration by acting out an object’s behaviors.
Design Patterns for Object Oriented systems CSC 515 Ashwin Dandwate.
Patterns Reusable solutions to common object-oriented programming problems When given a programming problem, re-use an existing solution. Gang of Four.
(c) 2009 University of California, Irvine – André van der Hoek1June 13, 2015 – 21:42:16 Informatics 122 Software Design II Lecture 8 André van der Hoek.
Design Patterns. What are design patterns? A general reusable solution to a commonly occurring problem. A description or template for how to solve a problem.
Design Patterns Part IV (TIC++V2:C10) Yingcai Xiao 10/01/08.
DESIGN PATTERNS Redesigning Applications And
© Copyright Eliyahu Brutman Programming Techniques Course.
Dept. of Computer Engineering, Amir-Kabir University 1 Design Patterns Dr. Noorhosseini Lecture 2.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Design Patterns.
(c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.
Design Patterns Module Name - Object Oriented Modeling By Archana Munnangi S R Kumar Utkarsh Batwal ( ) ( ) ( )
Basic Design Patterns 1. Introduction Gabriel Mañana Ed. 453 Of. 120 Ext
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.
Design Patterns Discussion of pages: xi-11 Sections: Preface, Forward, Chapter
Design Patterns Alan Shalloway, James Trott, Design Patterns Explained, Addison-Wesley, Gamma, Helm, Johnson, Vlissides, Design Patterns, Elements.
Design Patterns.
Software Waterfall Life Cycle Requirements Construction Design Testing Delivery and Installation Operations and Maintenance Concept Exploration Prototype.
Engineering of Software II Spring Why Design Patterns? Problems The hard part about object-oriented design is decomposing a system into objects.
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Design Patterns in Java Chapter 1 Introduction Summary prepared by Kirk Scott 1.
Powerpoint Templates Page 1 Powerpoint Templates What is Design Patterns ? by Indriati Teknik Informatika – UB.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 27. Review UML dynamic view – State Diagrams.
Patterns and Reuse. Patterns Reuse of Analysis and Design.
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns IX Interpreter, Mediator, Template Method recap.
DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
Design Patterns CS 124 Reference: Gamma et al (“Gang-of-4”), Design Patterns.
Design Principle & Patterns by A.Surasit Samaisut Copyrights : All Rights Reserved.
ECE450S – Software Engineering II
1 A Brief Introduction to Design Patterns Based on materials from Doug Schmidt 1.
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
Introduction to Design Patterns. Questions What is a design pattern? Who needs design patterns? How different are classes and objects in APL compared.
DESIGN PATTERNS COMMONLY USED PATTERNS What is a design pattern ? Defining certain rules to tackle a particular kind of problem in software development.
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.
CS616: Software Engineering Spring 2009 Design Patterns Sami Taha.
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
Design Patterns Introduction
1 Chapter 5:Design Patterns. 2 What are design pattern?  Schematic description of design solution to recurring problems in software design and,  Reusable.
BEHAVIORAL PATTERNS 13-Sep-2012 Presenters Sanjeeb Kumar Nanda & Shankar Gogada.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 31. Review Creational Design Patterns – Singleton Pattern – Builder Pattern.
CS251 – Software Engineering Lectures 18: Intro to DP Slides by Rick Mercer, Christian Ratliff, Oscar Nierstrasz and others 1 و ابتغ فيما آتاك الله الدار.
Design Patterns Introduction “Patterns are discovered, not invented” Richard Helm.
The Strategy Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Five Minute Design Patterns Doug Marttila Forest and the Trees May 30, 2009 Template Factory Singleton Iterator Adapter Façade Observer Command Strategy.
1 Good Object-Oriented Design Dr. Radu Marinescu Lecture 4 Introduction to Design Patterns.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
Design Patterns: MORE Examples
Design Patterns: Brief Examples
Chapter 10 Design Patterns.
Chapter 5:Design Patterns
Software Design Patterns
Introduction to Design Patterns
Design Patterns Lecture part 2.
A Brief Introduction to Design Patterns
Introduction to Design Patterns
object oriented Principles of software design
Software Engineering Lecture 7 - Design Patterns
Informatics 122 Software Design II
DESIGN PATTERNS : Introduction
Informatics 122 Software Design II
Presentation transcript:

Dept. of Computer Engineering, Amirkabir University of Tech. 1 Design Patterns Dr. Noorhosseini Introduction

Dept. of Computer Engineering, Amirkabir University of Tech. 2 Introduction Designing OO software is not easy. Designing Reusable OO software is really hard. Why? Reusable OO software is not generated in the first attempt. Experienced designers however make good design. It takes a long time for a novice designer to learn what a good OO design is. So there is something that an experienced designer must know that a novice one doesn’t. What’s that?

Dept. of Computer Engineering, Amirkabir University of Tech. 3 Introduction (cont) Experienced designers know NOT to solve every problem from scratch. Rather they use (reuse) solutions that have worked for them in the past. ( e.g. setting up a socket connection using c lib) In other words they have developed a pattern in their mind. A good designer will also polish these patterns on every use and even a better designer documents these patterns for future use by himself or others.

Dept. of Computer Engineering, Amirkabir University of Tech. 4 Introduction (cont..) This is the subject of this course, patterns that get used repeatedly in many software projects. We want to prevent re-invention of the wheels A designer who is familiar with these patterns can apply them immediately to design problems without having to re-discover them.

Dept. of Computer Engineering, Amirkabir University of Tech. 5 The benefits of knowing these patterns More elegant design More readable design. Easier communication with co-designer (better understanding among team members) Easier understanding of existing code (over %80 of an engineer’s job) Faster and more reliable design etc..

Dept. of Computer Engineering, Amirkabir University of Tech. 6 What is a design pattern? Design patterns are not about designs such as linked lists and hash tables that can be coded in classes and reused as is. Nor are they complex, domain-specific designs for an entire application Design patterns are description of communicating objects and classes that are customized to solve a general design problem in a particular context. They are flexible, elegant, proven and reusable solutions to design problems.

Dept. of Computer Engineering, Amirkabir University of Tech. 7 MVC (quick review) MVC  Model: application object  View: screen presentation  Controller: defines the way the user interface reacts to user input Diagram on board

Dept. of Computer Engineering, Amirkabir University of Tech. 8 An example: MVC model Model/View/Controller (MVC) triad of classes is an example of a structural pattern used to build user interfaces Three kind of classes: The model (application objects), the view (its screen presentation), the controller (how view reacts to user input) Before, UI design tend to lump these together Decoupling of MVC, many advantages, e.g. one model and several views, adding new views without changing model, changing model without affecting views, …

Dept. of Computer Engineering, Amirkabir University of Tech. 9

10 MVC (cont..) The ideas behind MVC: - decoupling objects so that changes to one can affect many others without the need for changed object to know details of the others. The more general design is described by Observer pattern. - MVC let you change responses to input without affecting the views. Depending on the context we can have different reaction to the same input. Having a controller object let us encapsulate the response. The view-controller relationship is an example of the Strategy design pattern.

Dept. of Computer Engineering, Amirkabir University of Tech. 11 MVC Design Pattern Examples Observer Pattern:  decoupling of model from view  changes to one object can affect multiple views, without requiring object to know details of view Composite Pattern:  nesting of views  class hierarchy in which some subclasses define primitive objects and other classes define composite objects that assemble primitives into more complex objects Strategy Pattern:  view-controller relationship allows controller to replaced statically or dynamically

Dept. of Computer Engineering, Amirkabir University of Tech. 12 Main elements of a design pattern Name: Facilitates communication Problem: context of application, when to apply Solution: Elements that makeup the Design Consequences: Results and trade offs of applying the pattern

Dept. of Computer Engineering, Amirkabir University of Tech. 13 Design Pattern Template Classification Intent Other names Motivation Applicability Structure Participants Collaborations Implementation Sample code Known uses Related Patterns

Dept. of Computer Engineering, Amirkabir University of Tech. 14 Template cont.. Pattern Name and Classification: Succinct, captures essences of pattern, reflects scheme Intent: Short statement that answers the following:  What does it do?  What is its rationale and intent  What particular design issue or problem does it address?

Dept. of Computer Engineering, Amirkabir University of Tech. 15 Template cont.. Also Know As: aliases Motivation: Scenario which illustrates the design problem and how class and object structures in the pattern solve the problem. Applicability:  When design pattern can be applied  Examples of poor design the pattern can address  How to recognize design patterns

Dept. of Computer Engineering, Amirkabir University of Tech. 16 Template cont.. Structure: Graphical representation of classes in the design pattern using OMT (Object Modeling Technique). Also utilizes interaction diagrams. Participants: Classes and/or objects participating in the design pattern and their responsibilities. Collaborations: How participants carry out their responsibilities.

Dept. of Computer Engineering, Amirkabir University of Tech. 17 Template cont.. Consequences:  How a design pattern supports its objectives  Trade-offs, results of using design pattern  Aspects of system which can vary independently Implementation:  pitfalls, hints or techniques  language-specific issues Sample Code: Code fragments in C++ or Java

Dept. of Computer Engineering, Amirkabir University of Tech. 18 Template cont.. Known Uses: At least two examples of the pattern found in real systems. Related Patterns:  What patterns are closely related?  Important differences between closely related patterns.  Which patterns is this design pattern used with?

Dept. of Computer Engineering, Amirkabir University of Tech. 19 Organization of Catalog Design patterns vary in granularity and level of abstraction. Families of related patterns help to programmer to learn patterns faster and can direct efforts to find new patterns. 23 design patterns total

Dept. of Computer Engineering, Amirkabir University of Tech. 20 Two classifications of a design pattern Purpose: What a design pattern does Scope: Specifies whether a design pattern applies primarily to classes or to objects

Dept. of Computer Engineering, Amirkabir University of Tech. 21 Design Pattern Purpose Creational (5): Concerns object creation Structural (7): Deals with composition of classes or objects Behavioral (11): Characterizes ways in which classes or objects interact and distribute responsibility.

Dept. of Computer Engineering, Amirkabir University of Tech. 22 The Catalog of Design Patterns CreationalStructuralBehavioral Factory MethodAdapterInterpreter Template Method Abstract Factory Builder Prototype Singleton Adapter (object) Bridge Composite Decorator Façade Flyweight Proxy Chain of Responsibility Command Iterator Mediator Observer State Strategy Visitor Scope Class Object

Dept. of Computer Engineering, Amirkabir University of Tech. 23 Design Pattern Scope Class Patterns (4)  Deal with relationships between classes and their subclasses  Relationships established through inheritance, so they are fixed at compile time (static) Object patterns (20)  Deal with object relationships  Relationships can be changed at runtime (dynamic)

Dept. of Computer Engineering, Amirkabir University of Tech. 24 Six types of design patterns 1. Creational class patterns defer some part of object creation to subclasses 2. Creational object patterns defer some part of object creation to another object 3. Structural class patterns use inheritance to compose classes 4. Structural object patterns describe ways to assemble objects 5. Behavioral class patterns use inheritance to describe algorithms and flow of control 6. Behavioral object patterns describe how a group of objects cooperate to perform a task that no single object can carry out alone

Dept. of Computer Engineering, Amirkabir University of Tech. 25 Additional ways to organize design patterns Patterns which are used together Some patterns are alternatives for one another Some patterns result in similar design although they have different intents Patterns which reference one another (see Figure 1.1, p. 12) Additional ways to organize design patterns

Dept. of Computer Engineering, Amirkabir University of Tech. 26 What don’t these design patterns apply to? Concurrency Distributed programming Real-time programming Domain-specific patterns User interface design Device drivers Object-oriented DB

Dept. of Computer Engineering, Amirkabir University of Tech. 27 Course Outline Introduction to the course Review of some OO design problems and some OO design concepts. How design patterns can solve design problems A case Study. Showing some design problems and solutions leading to some patterns. Reviewing pattern structure and other attributes and some sample code related to the use case. Review of the rest of patterns, finding use cases (collaboratively with class) Your presentation of use cases in your assignments Midterm & Final Exam

Dept. of Computer Engineering, Amirkabir University of Tech. 28 What you need to know to excel in this course Good knowledge and experience with OO design Knowledge of Java or C++ Design and coding experience. You must have experienced solving a problem over and over to appreciate the patterns presented

Dept. of Computer Engineering, Amirkabir University of Tech. 29 Course requirements Group assignments %30 Student presentations of the assignment solutions Class work %15 Midterm & Final Exams %25 &%25 Class participation %10 Students will be penalized for being absent from lectures and for late delivery of assignments