WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.

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.
DESIGN PATTERNS OZGUR RAHMI DONMEZ.
Patterns Reusable solutions to common object-oriented programming problems When given a programming problem, re-use an existing solution. Gang of Four.
05/26/2004www.indyjug.net1 Indy Java User’s Group June Knowledge Services, Inc.
IEG3080 Tutorial 7 Prepared by Ryan.
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 Module Name - Object Oriented Modeling By Archana Munnangi S R Kumar Utkarsh Batwal ( ) ( ) ( )
CERN – European Organization for Nuclear Research GS Department – Administrative Information Services Design Patterns in Groovy Nicolas Décrevel Advanced.
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
Design Patterns Standardized Recurring model Fits in many location Opposite of customization Fundamental types of pattern Choose and use as desired and.
CSSE 374: Introduction to Gang of Four Design Patterns
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
CSSE 374: 3½ Gang of Four Design Patterns These slides derived from Steve Chenoweth, Shawn Bohner, Curt Clifton, and others involved in delivering 374.
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
Object Oriented Software Engineering Chapter 16 and 17 review 2014/06/03.
CSE 403 Lecture 14 Design Patterns. Today’s educational objective Understand the basics of design patterns Be able to distinguish them from design approaches.
Design Patterns CS 124 Reference: Gamma et al (“Gang-of-4”), Design Patterns.
Methods: Deciding What to Design In-Young Ko iko.AT. icu.ac.kr Information and Communications University (ICU) iko.AT. icu.ac.kr Fall 2005 ICE0575 Lecture.
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.
Creational Patterns
What to know for the exam. Smalltalk will be used for questions, but there will not be questions about the grammar. Questions might ask – how particular.
Proxy.
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
Design Patterns. 1 Paradigm4 Concepts 9 Principles23 Patterns.
Design Patterns Introduction
Design Patterns SE464 Derek Rayside images from NetObjectives.com & Wikipedia.
Java Design Patterns Java Design Patterns. What are design patterns? the best solution for a recurring problem a technique for making code more flexible.
CS251 – Software Engineering Lectures 18: Intro to DP Slides by Rick Mercer, Christian Ratliff, Oscar Nierstrasz and others 1 و ابتغ فيما آتاك الله الدار.
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
Chapter 10 Design Patterns.
樣式導向設計 (Pattern-Oriented Design) 課程簡介
Chapter 5:Design Patterns
MPCS – Advanced java Programming
Common Design Patterns
Design Patterns Lecture part 2.
Introduction to Design Patterns
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
How to be a Good Developer
Design Patterns with C# (and Food!)
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
object oriented Principles of software design
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
Design Patterns in Game Design
Informatics 122 Software Design II
CSE 403 Software Design.
Design Patterns Part 2: Factory, Builder, & Memento
Informatics 122 Software Design II
Chapter 8, Design Patterns Singleton
Presentation transcript:

WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010. They may not show up well on other PowerPoint versions. You can download PowerPoint 2010 viewer from here. These slides contain a lot of animations. For optimal results, watch in slideshow mode.

One-and-only-one object, shared among others

One-and-only-one object, shared among others Problem: how to avoid multiple objects?

One-and-only-one object, shared among others Solution: Logic +Logic( ) + getInstance( ) : Logic Logic - Logic( ) + getInstance( ) : Logic

One-and-only-one object, shared among others Solution: Logic - theOne : Logic - Logic( ) + getInstance( ) : Logic

One-and-only-one object, shared among others Solution: public static Logic getInstance(){ if (theOne == null) theOne = new Logic(); return theOne; } Logic - theOne : Logic - Logic( ) + getInstance( ) : Logic //somewhere else in the system… Logic logic = Logic.getInstance(); //instead of … Logic logic = new Logic();

Using patterns to solve recurring problems Part I Déjà vu: Using patterns to solve recurring problems Part I CS2103/T, Lecture 9, Part 2, [March, 2018]

Using patterns to solve recurring problems Déjà vu: Using patterns to solve recurring problems

Using patterns to solve recurring problems experience Déjà vu: Using patterns to solve recurring problems

experience … is what you get when you didn’t get what you wanted.

experience … is valuable.

Learning from experience … is too costly.

experience Learning from Note to self: never volunteer to be the headstand guy

Learning from experience Patterns

Context: One-and-only-one Logic object, but shared by others Problem: Need to control the construction of the Logic object, but allow sharing Solution: Use private constructor and maintain a static reference for the only copy of the Logic object Logic - theOne : Logic - Logic( ) + getInstance( ) : Logic

Name: Singleton Pattern Context: One-and-only-one object, but shared by others Problem: Need to control the construction, but allow sharing Solution: Use private constructor and maintain a static reference for the only copy of the object Logic - theOne : Logic - Logic( ) + getInstance( ) : Logic Singleton - theOne : Singleton - Singleton( ) + getInstance( ) : Singleton

Name: Singleton Pattern Context: One-and-only-one object, but shared by others Problem: Need to control the construction, but allow sharing Solution: Use private constructor and maintain a static reference for the only copy of the object [An elegant solution to a recurring problem] Pattern Singleton - theOne : Singleton - Singleton( ) + getInstance( ) : Singleton

Name: Singleton Pattern Context: One-and-only-one object, but shared by others Problem: Need to control the construction, but allow sharing Solution: Use private constructor and maintain a static reference for the only copy of the object [An elegant solution to a recurring problem] Pattern <<Singleton>> - theOne : <<Singleton>> - Singleton( ) + getInstance( ) : <<Singleton>>

Name: Singleton Pattern … for that, I used the Name: Singleton Pattern Show off ! Context: One-and-only-one object, but shared by others Problem: Need to control the construction, but allow sharing Solution: Use private constructor and maintain a static reference for the only copy of the object <<Singleton>> - theOne : <<Singleton>> - Singleton( ) + getInstance( ) : <<Singleton>>

Patterns = a high-level vocabulary

[A stupid solution to a recurring problem] Anti-Pattern Context: One-and-only-one object, but shared by others Problem: Need to control the construction, but allow sharingSolution: Represent abstraction and occurrences as different classes.

[A stupid solution to a recurring problem] Anti-Pattern Context: One-and-only-one object, but shared by others Problem: Need to control the construction, but allow sharingSolutionSolution: Represent abstraction and occurrences as different classes.

1. Singleton 2. Façade 3. Command

1. Singleton 2. Façade 3. Command

1. Singleton 2. Façade 3. Command Logic UI ATD

1. Singleton 2. Façade 3. Command Logic TextUI MSLogic ATD

<<Façade>> 1. Singleton 2. Façade 3. Command <<Client1>> <<Façade>> <<Client2>>

User commands are kept as objects 1. Singleton 2. Façade 3. Command Edit User commands are kept as objects Sort Delete

Explain this design in less than 5 words, without diagrams or code Command cmd = createCommand(commandString); cmd.execute(); history.add(cmd); … cmd.undo(); {abstract} Command execute() {abstract} undo() {abstract} Edit execute() undo() Delete Add History add(Command) *

1. Singleton 2. Façade 3. Command

Learning → Applying

Learning → Applying

Learning → Applying

GoF patterns Learning → Applying Creational: Behavioral : Abstract Factory Builder Factory Method Prototype Singleton Behavioral : Chain of Responsibility Command Interpreter Template Method Iterator Memento State Visitor Mediator Observer Strategy Structural: Adapter Bridge Composite Decorator Façade Flyweight Proxy GoF patterns

Learning → Applying

Learning → Applying Pattern So many patterns, so little time…

Learning → Applying Pattern So many patterns, so little time…

Learning → Applying Pattern So many patterns, so little time…

Which pattern can you apply in your project? Learning → Applying Which pattern can you apply in your project?

Learning → Applying

1. Singleton 2. Façade 3. Command 4. More to come…. Identify patterns in sample code Use more patterns if it helps Should be able to relate each pattern to the project