Design Patterns. An introduction

Similar documents
Software Design Patterns. Background 1. Background 2. Jonathan I. Maletic, Ph.D.

Ingegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1

Design Patterns. Gunnar Gotshalks A4-1

DESIGN PATTERN - INTERVIEW QUESTIONS

Using Design Patterns in Java Application Development

Ingegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1

Design Pattern What is a Design Pattern? Design Pattern Elements. Almas Ansari Page 1

SDC Design patterns GoF

CS/CE 2336 Computer Science II

Slide 1. Design Patterns. Prof. Mirco Tribastone, Ph.D

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

Design Pattern. CMPSC 487 Lecture 10 Topics: Design Patterns: Elements of Reusable Object-Oriented Software (Gamma, et al.)

Object Oriented Methods with UML. Introduction to Design Patterns- Lecture 8

Design Patterns. Observations. Electrical Engineering Patterns. Mechanical Engineering Patterns

Trusted Components. Reuse, Contracts and Patterns. Prof. Dr. Bertrand Meyer Dr. Karine Arnout

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar

Design Patterns. Manuel Mastrofini. Systems Engineering and Web Services. University of Rome Tor Vergata June 2011

Tuesday, October 4. Announcements

Design Patterns. CSE870: Advanced Software Engineering (Design Patterns): Cheng

Design Patterns! Acknowledgements!

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar

Foundations of Software Engineering Design Patterns -- Introduction

A Reconnaissance on Design Patterns

LECTURE NOTES ON DESIGN PATTERNS MCA III YEAR, V SEMESTER (JNTUA-R09)

Design Patterns. Hausi A. Müller University of Victoria. Software Architecture Course Spring 2000

Object-Oriented Design

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

Idioms and Design Patterns. Martin Skogevall IDE, Mälardalen University

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 6: Design Patterns

Object-oriented Software Design Patterns

3 Product Management Anti-Patterns by Thomas Schranz

Applying the Observer Design Pattern

Lecture 13: Design Patterns

Work groups meeting 3

What is Design Patterns?

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

Pattern Resources. Lecture 25: Design Patterns. What are Patterns? Design Patterns. Pattern Languages of Programming. The Portland Pattern Repository

Applying the Decorator Design Pattern

CS251 Software Engineering Lectures 18: Intro to DP

Goals of Lecture. Lecture 27: OO Design Patterns. Pattern Resources. Design Patterns. Cover OO Design Patterns. Pattern Languages of Programming

Topics in Object-Oriented Design Patterns

MVC. Model-View-Controller. Design Patterns. Certain programs reuse the same basic structure or set of ideas

Software Engineering - I An Introduction to Software Construction Techniques for Industrial Strength Software

CSE870: Advanced Software Engineering (Cheng) 1

CPSC 310 Software Engineering. Lecture 11. Design Patterns

Keywords: Abstract Factory, Singleton, Factory Method, Prototype, Builder, Composite, Flyweight, Decorator.

Applying Design Patterns to accelerate development of reusable, configurable and portable UVCs. Accellera Systems Initiative 1

Lectures 24 and 25 Introduction to Architectural Styles and Design Patterns

Object-Oriented Oriented Programming

A Rapid Overview of UML

Review Software Engineering October, 7, Adrian Iftene

An Introduction to Patterns

Socket attaches to a Ratchet. 2) Bridge Decouple an abstraction from its implementation so that the two can vary independently.

INSTITUTE OF AERONAUTICAL ENGINEERING

Coordination Patterns

An Introduction to Patterns

Object Oriented Paradigm

Chapter 12 (revised by JAS)

Introduction and History

Software Design COSC 4353/6353 D R. R A J S I N G H

Crash course on design patterns

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

1 Software Architecture

administrivia today UML start design patterns Tuesday, September 28, 2010

be used for more than one use case (for instance, for use cases Create User and Delete User, one can have one UserController, instead of two separate

CSCI 253. Overview. The Elements of a Design Pattern. George Blankenship 1. Object Oriented Design: Iterator Pattern George Blankenship

Design patterns. OOD Lecture 6

Object-Oriented Design

Design Pattern Detection

Application Architectures, Design Patterns

APPLYING DESIGN PATTERNS TO SCA IMPLEMENTATIONS

UNIT I Introduction to Design Patterns

Reuse at Design Level: Design Patterns

Facade and Adapter. Comp-303 : Programming Techniques Lecture 19. Alexandre Denault Computer Science McGill University Winter 2004

The Strategy Pattern Design Principle: Design Principle: Design Principle:

Design Pattern Detection

Applying the Factory Method Design Pattern

Work groups meeting 3

DESIGN PATTERNS SURESH BABU M ASST PROFESSOR VJIT

Extensibility Design Patterns From The Initial Stage of Application Life-Cycle

Introduction to Software Engineering: Object Design I Reuse & Patterns

Software Reengineering Refactoring To Patterns. Martin Pinzger Delft University of Technology

Design Patterns: Elements of Reusable Object Oriented Software. Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides

Patterns. Erich Gamma Richard Helm Ralph Johnson John Vlissides

What is Design Patterns?

Design pa*erns. Based on slides by Glenn D. Blank

6.3 Patterns. Definition: Design Patterns

Lecture Material. Design Patterns. Visitor Client-Server Factory Singleton

Design Patterns #3. Reid Holmes. Material and some slide content from: - GoF Design Patterns Book - Head First Design Patterns

A Metric for Measuring the Abstraction Level of Design Patterns

Design Patterns. Dr. Rania Khairy. Software Engineering and Development Tool

Introduction to Patterns and Frameworks

SOFTWARE ENGINEERING SOFTWARE DESIGN. Saulius Ragaišis.

A Primer on Design Patterns

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar

Software Engineering I (02161)

Lecture 20: Design Patterns II

Overview of Patterns: Introduction

SYLLABUS CHAPTER - 1 [SOFTWARE REUSE SUCCESS FACTORS] Reuse Driven Software Engineering is a Business

CSC7203 : Advanced Object Oriented Development. J Paul Gibson, D311. Design Patterns

Transcription:

Design Patterns An introduction

Introduction Designing object-oriented software is hard, and designing reusable object-oriented software is even harder. Your design should be specific to the problem at hand but also general enough to address future problems and requirements. You also want to avoid redesign, or at least minimize it.

Good approach One thing expert designers know not to do is solve every problem from first principles. Rather, they reuse solutions that have worked for them in the past. When they find a good solution, they use it again and again.

Design Patterns Design patterns represent the best practices used by experienced object-oriented software developers. Design patterns are solutions to general problems that software developers faced during software development. These solutions were obtained by trial and error by numerous software developers over quite a substantial period of time.

Design Patterns In software engineering, a design pattern is a general repeatable solution to a commonly occurring problem in software design. A design pattern isn't a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations.

What is a Design Pattern? Christopher Alexander, A Pattern Language, 1977.says, "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"

What is Gang of Four (GOF)? In 1994, four authors Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides published a book titled Design Patterns - Elements of Reusable Object-Oriented Software which initiated the concept of Design Pattern in Software development. These authors are collectively known as Gang of Four (GOF).

Essential elements The pattern name is a handle we can use to describe a design problem, its solutions, and consequences in a word or two. The problem describes when to apply the pattern. It explains the problem and its context. It might describe specific design problems such as how to represent algorithms as objects. Sometimes the problem will include a list of conditions that must be met before it makes sense to apply the pattern.

The solution describes the elements that make up the design, their relationships, responsibilities, and collaborations. The solution doesn' t describe a particular concrete design or implementation, because a pattern is like a template that can be applied in many different situations.

The consequences are the results and trade-offs of applying the pattern. The consequences for software often concern space and time trade-offs. They may address language and implementation issues as well. Since reuse is often a factor in object-oriented design, the consequences of a pattern include its impact on a system's flexibility, extensibility, or portability.

Describing Design Patterns How do we describe design patterns? Graphical notations, while important and useful, aren't sufficient. They simply capture the end product of the design process as relationships between classes and objects. To reuse the design, we must also record the decisions, alternatives, and trade-offs that led to it. We describe design patterns using a consistent format.

Template Pattern Name Intent Also Known As Motivation Applicability Structure Participants Collaborations Consequences Implementation Sample Code Known Uses Related Patterns

Pattern Name and Classification The pattern' s name conveys the essence of the pattern succinctly. A good name is vital, because it will become part of your design vocabulary. Intent A short statement that answers the following questions: What does the design pattern do? What is its rationale and intent? What particular design issue or problem does it address?

Also Known As Other well-known names for the pattern, if any. Motivation A scenario that illustrates a design problem and how the class and object structures in the pattern solve the problem. The scenario will help you understand the more abstract description of the pattern that follows.

Applicability What are the situations in which the design pattern can be applied? What are examples of poor designs that the pattern can address? How can you recognize these situations? Structure A graphical representation of the classes in the pattern using a notation based on the Object Modelling Technique (OMT). We also use interaction diagrams to illustrate sequences of requests and collaborations between objects.

Participants The classes and/or objects participating in the design pattern and their responsibilities. Collaborations How the participants collaborate to carry out their responsibilities

Consequences How does the pattern support its objectives? What are the trade-offs and results of using the pattern? Implementation What pitfalls, hints, or techniques should you be aware of when implementing the pattern? Are there language-specific issues?

Sample Cod Code fragments that illustrate how you might implement the pattern in C++ or any other PL. Known Uses Examples of the pattern found in real systems. We include at least two examples from different domains.

Related Patterns A short statement that answers the following questions: What design patterns are closely related to this one? What are the important differences? With which other patterns should this one be used?

Types of Design Patterns As per the design pattern reference book Design Patterns - Elements of Reusable Object-Oriented Software, there are 23 design patterns which can be classified in three categories: Creational, Structural and Behavioral patterns.

Creational Patterns These design patterns provide a way to create objects while hiding the creation logic, rather than instantiating objects directly using new opreator. This gives program more flexibility in deciding which objects need to be created for a given use case.

Structural Patterns These design patterns concern class and object composition. Concept of inheritance is used to compose interfaces and define ways to compose objects to obtain new functionalities.

Behavioral Patterns These design patterns are specifically concerned with communication between objects.

Types of Patterns Creational patterns: Deal with initializing and configuring classes and objects Structural patterns: Deal with decoupling interface and implementation of classes and objects Composition of classes or objects Behavioral patterns: Deal with dynamic interactions among societies of classes and objects How they distribute responsibility

Creational Patterns Abstract Factory: Factory for building related objects Builder: Factory for building complex objects incrementally Factory Method: Method in a derived class creates associates Prototype: Factory for cloning new instances from a prototype Singleton: Factory for a singular (sole) instance

Structural Patterns Adapter: Translator adapts a server interface for a client Bridge: Abstraction for binding one of many implementations Composite: Structure for building recursive aggregations Decorator: Decorator extends an object transparently Facade: Simplifies the interface for a subsystem Flyweight: Many fine-grained objects shared efficiently. Proxy: One object approximates another

Behavioral Patterns Chain of Responsibility: Request delegated to the responsible service provider Command: Request is first-class object Iterator: Aggregate elements are accessed sequentially Interpreter: Language interpreter for a small grammar Mediator: Coordinates interactions between its associates Memento: Snapshot captures and restores object states privately

Behavioral Patterns (cont.) Observer: Dependents update automatically when subject changes State: Object whose behavior depends on its state Strategy: Abstraction for selecting one of many algorithms Template Method: Algorithm with some steps supplied by a derived class Visitor: Operations applied to elements of a heterogeneous object structure

What Makes it a Pattern? A Pattern must: Solve a problem and be useful Must describe where the solution can be used Provide sufficient understanding to tailor the solution Have a name and be referenced consistently

Benefits of Design Patterns Design patterns enable large-scale reuse of software architectures and also help document systems Patterns explicitly capture expert knowledge and design trade-offs and make it more widely available Patterns help improve developer communication

Drawbacks to Design Patterns Patterns do not lead to direct code reuse Teams may suffer from pattern overload Patterns are validated by experience and discussion rather than by automated testing Integrating patterns into a software development process is a humanintensive activity.

Thank you