An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.

Slides:



Advertisements
Similar presentations
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.
Advertisements

18-1 Verifying Object Behavior and Collaboration Role playing – the act of simulating object behavior and collaboration by acting out an object’s behaviors.
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.
Dept. of Computer Engineering, Amirkabir University of Tech. 1 Design Patterns Dr. Noorhosseini Introduction.
Design Patterns CS is not simply about programming
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.
Software Engineering I Object-Oriented Design Software Design Refinement Using Design Patterns Instructor: Dr. Hany H. Ammar Dept. of Computer Science.
DESIGN PATTERNS Redesigning Applications And
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 ( ) ( ) ( )
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.
Vrije Universiteit amsterdamPostacademische Cursus Informatie Technologie Idioms and Patterns polymorphism -- inheritance and delegation idioms -- realizing.
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 Design Refinement Using Design Patterns Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
Case Studies on Design Patterns Design Refinements Examples.
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.
COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
GoF Sections Design Problems and Design Patterns.
DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
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
Introduction to Design Patterns. Questions What is a design pattern? Who needs design patterns? How different are classes and objects in APL compared.
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.
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
Stephenson College DP 98 1 Design Patterns by Derek Peacock.
Design Patterns. 1 Paradigm4 Concepts 9 Principles23 Patterns.
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
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.
Design Patterns Introduction “Patterns are discovered, not invented” Richard Helm.
CS 210 Proxy Pattern Nov 16 th, RMI – A quick review A simple, easy to understand tutorial is located here:
CS 5150 Software Engineering Lecture 16 Program Design 3.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
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.
Design Patterns Creational Patterns. Abstract the instantiation process Help make the system independent of how its objects are created, composed and.
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
MPCS – Advanced java Programming
Design Patterns Lecture part 2.
Introduction to Design Patterns
Instructor: Dr. Hany H. Ammar
object oriented Principles of software design
Software Engineering Lecture 7 - Design Patterns
Informatics 122 Software Design II
Object Oriented Design Patterns - Structural Patterns
Patterns.
Object-Oriented Design
DESIGN PATTERNS : Introduction
Informatics 122 Software Design II
Chapter 8, Design Patterns Introduction
Presentation transcript:

An Introduction to Design Patterns

Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers. “Design patterns help a designer get a design right faster”.

Introduction Are based on the principles of object-oriented programming: abstraction, inheritance, polymorphism and association. Are solutions to recurring problems to software design. Are independent of the application domain. Example – Variability of interfaces – the modeller view controller (MVC) pattern.

The Downside Although design patterns are useful in promoting flexibility, this maybe at the expense of a more complicated design. There does not exist A standardization for indexing patterns General practices/processes for using design patterns during the design process have not as yet been established.

Object-Oriented Principles Involves identifying: Classes and objects What to encapsulate Association hierarchies Inheritance hierarchies Interface hierarchies Object-oriented designs are evaluated in terms of how reusable, extensible and maintainable they are.

Principles of Object-Oriented Design Encapsulate what varies. Design/program to an interface and not to an implementation. Favour the use of association of the use of inheritance.

Types of Pattern – Catalog 1 Creational patterns - Focus on the best way to create instances of objects to promote flexibility, e.g. factory pattern. Structural patterns - Focus on the composition of classes and objects into larger structures, e.g. the adapter pattern. Behavioural patterns - Focus on the interaction between classes or objects, e.g. the observer pattern.

Types of Pattern – Catalog 2 Architectural patterns - Focus on the form of the overall system. Design patterns - Focus on the form of the subsystems making up the overall system and essentially provides schemes for refining them. Idioms - Describe the structure of the code and are specific to particular programming languages.

Relationships between Patterns Some patterns are used together, for example the composite pattern is sometimes used with iterator or visitor. Some patterns are also defined as alternatives for others, e.g. the prototype pattern can be used as alternative to the abstract factory pattern. Some patterns, e.g. the composite and decorator pattern, result in similar designs.

Pattern Scope The scope of a pattern specifies whether the pattern applies to classes or objects. Class patterns describe relationships between classes and their subclasses. These relationships are static. Object patterns describe the relationships between objects. Theses relationships can be changed at runtime.

Defining Patterns Are defined in terms of classes and objects and relationships between them. Using existing well-tested patterns saves time instead of deriving them from scratch each time. Patterns usually consist of smaller patterns/sub-patterns. Class diagrams are used to express design patterns.

Core Components of a Pattern The problem which the pattern was used to solve and the situation giving rise to the problem. A list of the conditions that must be met in order to apply the pattern may also be included. The core solution to the problem in terms of a description of the design rather than implementation details. Uses of the solution

A More Detailed Definition Name Intent of the pattern Aliases The problem Solution Example/s Applicability Structure Participants Collaborations Implementation Sample code Known uses Related patterns Consequences

Problems Solved by Design Patterns Finding appropriate objects. Determining the granularity of objects. Specifying object interfaces – definition of interfaces and relationships between them. Specifying object implementations. Using reuse mechanisms – delegation and parameterised types. Relating runtime and compile-time structures

Designing for Change A design must facilitate reuse and change. We need to design so as to avoid redesign. Certain design patterns can be used to prevent particular causes of redesign.

Avoiding Redesign Explicitly declaring class instances instead of using an interface -abstract factory, factory method and prototype patterns. Dependence of specific operations, i.e. using hard- coded requests - chain of responsibility and the command patterns. Limit software and hardware platform dependencies - abstract factory and bridge patterns. Dependance on object representations and implementations - Object representations and/or implementations may need to be changed - abstract factory, bridge, memento and proxy.

Avoiding Redesign Algorithmic dependencies - Algorithms that are likely to change should be isolated from the definition of the objects using them -builder, iterator, strategy, template and visitor patterns. Tight coupling - Tight coupling does not facilitate reuse- abstract factory, bridge, chain of responsibility, command, facade, mediator and observer patterns. Subclassing to extend functionality - Rather than using inheritance or association it maybe more efficient to combine both by creating one subclass that is associated with existing class - bridge, chain of responsibility, composite, decorator, observer and strategy classes. Difficulty in altering classes - In some cases adapting a class maybe difficult, e.g. the source code may not be available adapter, creator and visitor patterns.

Applying a Pattern In designing a system different patterns are used to design the different aspects of the system. Design patterns allow parts of the system to vary independently of other parts of the system. Patterns are often combined. Using one pattern my introduce further patterns into the design. Methods for applying design patterns and deciding which one to use.

Breaking Down the Problem Describe the problem and its subproblems. Select the category of patterns that is suitable for the design task. Compare the problem description with each pattern in the category. Identify the benefits and disadvantages of using each of the patterns in the category. Choose the pattern that best suits the problem.

Choosing a Design Pattern Consider the problems solved by design problems and what solution is needed for the problem at hand. Consider the intent of each pattern and which is most similar to the problem at hand. Analyse the relationships between patterns to determine which is the correct group of patterns to use. Determine whether creational, structural or behavioural patterns are needed and which of the patterns in the most suitable category is/are relevant to the problem at hand. Look at what could cause redesign for the problem at hand and patterns that can be used to avoid this. Identify which aspect/s of the system need to varied independently and which patterns will cater for this.

Using a Design Pattern Obtain an overview of the pattern. Obtain an understanding of the classes and objects and relationships between them. Choose application-specific names for the components of the patterns. Define the classes. Choose application-specific names for the operations defined in the pattern. Implement the necessary operations and relationships.