An Introduction To Design Patterns Jean-Paul S. Boodhoo Independent Consultant

Slides:



Advertisements
Similar presentations
GoF State Pattern Aaron Jacobs State(305) Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.
Advertisements

SE2811 Week 7, Class 2 The Gang of Four and more … Lab Thursday: Quiz SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder.
Nevena Ackovska/Magdalena Kostoska Faculty of Computer Science and Engineering (FCSE) UKIM, Skopje, Macedonia 11 th DAAD Workshop on “Software Engineering.
Strategy Pattern1 Design Patterns 1.Strategy Pattern How to design for flexibility?
DESIGN PATTERNS OZGUR RAHMI DONMEZ.
Design Patterns for Object Oriented systems CSC 515 Ashwin Dandwate.
Design Patterns CS is not simply about programming
Spring 2010CS 2251 Design Patterns. Spring 2010CS 2252 What is a Design Pattern? "a general reusable solution to a commonly occurring problem in software.
The Decorator Design Pattern (also known as the Wrapper) By Gordon Friedman Software Design and Documentation September 22, 2003.
ECE 355 Design Patterns Tutorial Part 2 (based on slides by Ali Razavi) Presented by Igor Ivković
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 Trends and Case Study John Hurst June 2005.
Cf.OBJECTIVE (ANZ) Design Patterns and Form Processing Jaime Metcher Software Architect, Centre for Innovation in Professional Learning, University of.
Chapter 1: Introduction to Design Patterns. SimUDuck Example.
Case Studies on Design Patterns Design Refinements Examples.
CS 325: Software Engineering March 17, 2015 Applying Patterns (Part A) The Façade Pattern The Adapter Pattern Interfaces & Implementations The Strategy.
CSSE 374: Introduction to Gang of Four Design Patterns
Aniruddha Chakrabarti
BTS430 Systems Analysis and Design using UML Design Patterns.
Creational Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Patterns in programming 1. What are patterns? “A design pattern is a general, reusable solution to a commonly occurring problem in software. A design.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 27. Review UML dynamic view – State Diagrams.
Y2 eProjects Session 4 – Advanced Topics. Objectives  Dynamic Models  Design Patterns (Optional)  Software testing (for S4) ACCP i7.1\Sem3_4\eProject\T4.
 How are you going to collaborate?  How are you going to divide up work?  How are you going to make sure that changes work with other people’s code?
Behavioral Design Patterns Morteza Yousefi University Of Science & Technology Of Mazandaran 1of 27Behavioral Design Patterns.
Strategy Design Patterns CS 590L - Sushil Puradkar.
CPSC 372 John D. McGregor Module 4 Session 1 Design Patterns.
Design Patterns Introduction to Design Patterns Eriq Muhammad Adams J. Mail : | Blog :
Refactoring1 Improving the structure of existing code.
L11-12: Design Patterns Definition Iterator (L4: Inheritance)‏ Factory (L4: Inheritance)‏ Strategy (L5: Multiple Inheritance)‏ Composite (L6: Implementation.
Patterns in programming1. 2 What are patterns? Answers to common design problems. A language used by developers –To discuss answers to design problems.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VIII Chain of Responsibility, Strategy, State.
Design Patterns Singleton & Factory Pattern Eriq Muhammad Adams J. Mail : | Blog :
05/26/2004www.indyjug.net1 Indy Java User’s Group May Knowledge Services, Inc.
CPSC 871 John D. McGregor Module 5 Session 1 Design Patterns.
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
Design Patterns: Elements of Reusable Object- Orientated Software Gamma, Helm, Johnson, Vlissides Presented By: David Williams.
Design Patterns. 1 Paradigm4 Concepts 9 Principles23 Patterns.
Design Patterns Introduction
CS 210 Introduction to Design Patterns August 29, 2006.
The State Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
The PROXY Design Pattern Oleksandra Sopova Feb, 2014.
Refactoring1 Improving the structure of existing code.
Proxy Pattern defined The Proxy Pattern provides a surrogate or placeholder for another object to control access to it by creating a representative object.
Watching the movie the hard way…. Page 256 – Head First Design Patterns.
CS 210 Proxy Pattern Nov 16 th, RMI – A quick review A simple, easy to understand tutorial is located here:
Seung Ha.  Façade is generally one side of the exterior of a building, especially the front.  Meaning “frontage” or “face”  In software architecture,
An object's behavior depends on its current state. Operations have large, multipart conditional statements that depend on the object's state.
STRATEGY PATTERN By Michelle Johnson. BACKGROUND Behavioral Pattern Allow you to define a family of algorithms, encapsulate each one, and make them interchangeable.
Patterns in programming
Design Patterns: MORE Examples
Abstract Factory & Command Pattern
Strategy Design Pattern
MPCS – Advanced java Programming
Introduction to Design Patterns
Design Patterns Introduction
Behavioral Design Patterns
Design Patterns.
Presented by Igor Ivković
State Design Pattern 1.
Improving the structure of existing code
Strategy Design Pattern
Design Patterns Imran Rashid CTO at ManiWeber Technologies.
Design Patterns (Gamma, Helm, Johnson, Vlissides)
Composite Design Pattern By Aravind Reddy Patlola.
Presented by Igor Ivković
Presentation transcript:

An Introduction To Design Patterns Jean-Paul S. Boodhoo Independent Consultant

The Problem How do I ensure that a class has only one instance of itself active for the application lifetime, as well as providing access to it?

The Singleton Pattern Ensures a class has only one instance, and provide a global point of access to it.

Hello Singleton

Singleton Tradeoffs Benefits Controlled access to a sole instance Bye bye global variables Liabilities Multihreading Issues Tighter coupling when not done correctly Difficult to test when not implemented correctly

The Problem Problem: Sort a list of People How many different ways can you sort a list of people?

Naive Sorting

What’s Wrong Hint – Think Open Closed Principle

The Strategy Pattern Define a family of algorithms, encapsulate each one, and make them interchangeable.

Sorting With The Strategy Pattern

Strategy Tradeoffs Benefits Remove the need to subclass Eliminate conditional processing. Liabilities Users of List must be aware of different strategies Potential class explosion.

The Problem An object in a program has an internal "state," and the behavior of the object needs to change when its state changes.

Messy State Implementation

The State Pattern Allows an object to alter its behaviour when its internal state changes. The object will appear to change its class.

Applying The State Pattern

State Tradeoffs Benefits New states can be added easily Goodbye messy conditionals Liabilities Potential class explosion Coupling between state classes (may not be a bad thing)

The Problem How do I convert the interface of one class into another interface that the client can work with?

The Adapter Pattern Converts the interface of a class into another interface the client expects.

The Adapter Pattern * Diagram shamelessly lifted from Head First Design Patterns

Applying The Adapter Pattern

Many Ways to Implement You can implement a design pattern 100 times and have it come out different each time. Start simple, don’t make your designs unnecessarily complicated.

Design Patterns Design Patterns Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides Addison-Wesley, 1995 Patterns of Enterprise Application Architecture Patterns of Enterprise Application Architecture Martin Fowler Addison-Wesley, 2003 Enterprise Integration Patterns Enterprise Integration Patterns Gregor Hohpe, Bobby Woolf Addison-Wesley, 2004 Pattern Catalogs Head First Design Patterns Eric Freeman & Elisabeth Freeman O’Reilly, 2004

Resources Design Pattern – Gamma,Helm,Johnson,Vlissides Head First Design Patterns – Eric Freeman and Elisabeth Freeman Refactoring to Patterns – Joshua Kerievsky – JP Boodhoo’s Web Site (had to throw that one in!!)