introduction

25
Design Patterns

Upload: rajesh-kumar

Post on 27-Jan-2015

533 views

Category:

Education


0 download

DESCRIPTION

Object-oriented analysis and design(OOAD) and Design Pattern Slides UML Slides. for more slides refer www.scmGalaxy.com

TRANSCRIPT

Page 1: Introduction

Design Patterns

Page 2: Introduction

Introduction to GOF - Design Patterns

Main Objective

• Motivation

• Design patterns

• Classification

• Selected Patterns

• Selecting and Using Design Patterns

Page 3: Introduction

Introduction to GOF - Design Patterns

Motivation

To develop reusable software

To reduce the depth of Class hierarchy

To develop high cohesive classes

Page 4: Introduction

Introduction to GOF - Design Patterns

Patterns Background

• What is a Pattern ?– A pattern is an abstract concrete form which keeps

recurring in specific contexts

“Patterns = Problem/solution pairs in a context”– Patterns capture the static and dynamic structure and

collaboration among key participants in software designs

– Patterns facilitate reuse of successful software architectures and designs

Page 5: Introduction

Introduction to GOF - Design Patterns

Qualities of Software Pattern

• Encapsulation and Abstraction

• Inheritance & composability

Page 6: Introduction

Introduction to GOF - Design Patterns

Reuse Types

• Source code

• Executables

• Object code

• Personnel

• Design

Page 7: Introduction

Introduction to GOF - Design Patterns

Approaches of Reusability

• Library routines• Overloading• Generic code / structures• Black box reuse ( composition )• White box reuse ( inheritance )• Toolkits: architecture independence• Frameworks: rigid architecture• Patterns: Problem, context & solution

Page 8: Introduction

Introduction to GOF - Design Patterns

Toolkits

• Often an application will incorporate classes from one or more libraries of predefined classes called toolkits.

• Set of related and reusable classes,Designed to provide useful general purpose functionality– E.g.: Set of classes for Lists, associative tables, stacks.

Page 9: Introduction

Introduction to GOF - Design Patterns

Framework

• Frameworks provide domain specific functionality- e.g. business application, telecommunication application, window system, distributed applications etc.

• It is semi-complete applications

// complete applications are developed by inheriting form and instantiating parameterized framework components

• Set of co-operating classes that make up a reusable design for a specific class of software systems

– Graphical editors for Multimedia domains like artistic drawing , music composition and CAD

– Compilers for different programming language and target machines

Page 10: Introduction

Introduction to GOF - Design Patterns

Framework

• Dictates architecture

• Captures design decisions common to application domain

• Emphasizes design reuse over code reuse

Page 11: Introduction

Introduction to GOF - Design Patterns

OO Frameworks

Page 12: Introduction

Introduction to GOF - Design Patterns

Frameworks v/s Design Patterns

Design patterns are more abstract than frameworks.- frameworks can be embodied in code but examples of patterns can be embodied in code

  Design patterns are smaller architectural elements

than frameworks.

- a typical framework contains several design patterns, but the reverse is never true

Design patterns are less specialized than frameworks. – patterns are independent of application

Page 13: Introduction

Introduction to GOF - Design Patterns

Page 14: Introduction

Introduction to GOF - Design Patterns

Design Patterns Description• Description of communicating objects and classes,

their roles and collaborations, and the distribution of responsibilities.

• customized to solve a general design problem in a particular context

• names, abstracts and identifies key aspects of a common design structure– useful for creating reusable object oriented design

• Focuses on a particular object oriented design problem or issue

Page 15: Introduction

Introduction to GOF - Design Patterns

Essential Element• Name• Problem• Solution• ConsequencesDocumentation & illustration Purpose

– Intent– Motivation– applicability– structure– Consequences– Sample Code

Page 16: Introduction

Introduction to GOF - Design Patterns

Classification

Purpose– Creational- concern process of object creation– Structural- deal with composition of classes or object– Behavioral- characterize ways in which classes or

objects interact and distribute responsibility

Scope– class– object

Page 17: Introduction

Introduction to GOF - Design Patterns

Design Pattern space

Page 18: Introduction

Introduction to GOF - Design Patterns

Session No Name Type

Session 1Factory MethodCreational

Session 2StrategyBehavioral

Session 3DecoratorStructural

Session 4CompositeStructural

Session 5IteratorBehavioral

Session 6Template MethodBehavioral

Session 7Abstract FactoryCreational

Page 19: Introduction

Introduction to GOF - Design Patterns

Session No Name Type

Session 8BuilderCreational

Session 9SingletonCreational

Session 10 Proxy Structural

Session 11 Adapter Structural

Session 12 Bridge Structural

Session 13 Mediator Behavioral

Session 14 Observer Behavioral

Page 20: Introduction

Introduction to GOF - Design Patterns

Session No Name Type

Session 15 Chain of Responsibility Behavioral

Session 16 Memento Behavioral

Session 17 Command Behavioral

Session 18 Prototype Creational

Session 19 State Behavioral

Session 20 Visitor Behavioral

Session 21 Facade Structural

Session 22 Flyweight Structural

Page 21: Introduction

Introduction to GOF - Design Patterns

Patterns concluding

I am top of the world!!

Page 22: Introduction

Introduction to GOF - Design Patterns

Page 23: Introduction

Introduction to GOF - Design Patterns

Page 24: Introduction

Introduction to GOF - Design Patterns

Selecting a Design Patterns

• Consider how design patterns solve design problem

• Scan intent section• Study how patterns interrelate• Study patterns of like purpose• Consider what should be variable in your

design• Examine a case of Redesign

Page 25: Introduction

Introduction to GOF - Design Patterns

Summary

• Reusable elements in a design

• Recurring similarity

• Increase representational power

• Favour object composition over class inheritance

• Delegation of an underlying principle

• Use Design Patterns whenever possible