1 Design Patterns prepared for COMP314, Bernhard Pfahringer see links on the web page as well!

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

Refactoring to Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
FINAL REVIEW. Stronger vs Weaker (one more time!) Requires less? Promises more? (stricter specifications on what the effects entail) Throws more exceptions?
C15: Design Patterns Gamma,Helm,Johnson,Vlissides (GOF)
Patterns Reusable solutions to common object-oriented programming problems When given a programming problem, re-use an existing solution. Gang of Four.
 Consists of Creational patterns  Each generator pattern has a Client, Product, and Generator.  The Generator needs at least one operation that creates.
. Plab – Tirgul 12 Design Patterns. Design Patterns u The De-Facto Book on Design Patterns:
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.
Spring 2010ACS-3913 Ron McFadyen1 Singleton To guarantee that there is at most one instance of a class we can apply the singleton pattern. Singleton Static.
DESIGN PATTERNS Redesigning Applications And
Chapter 3.4 Programming Fundamentals. 2 Data Structures Arrays – Elements are adjacent in memory (great cache consistency) – They never grow or get reallocated.
Singleton Christopher Chiaverini Software Design & Documentation September 18, 2003.
Design Patterns and Graphical User Interfaces Horstmann ,
Design patterns. What is a design pattern? Christopher Alexander: «The pattern describes a problem which again and again occurs in the work, as well as.
ECE 452 / CS 446 / SE464 Design Patterns: Part 2 - Answers A Tutorial By Peter Kim Partially based on the tutorial by Michał Antkiewicz.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Prof. Hertz (as told by xkcd.com)‏. Computer Science 313 – Advanced Programming Topics.
Abstract Factory Design Pattern making abstract things.
Factory Method A Creational Design Pattern. Factory Method Key Features  Defines an interface for creating objects without needing to know each object’s.
Chapter 26 GoF Design Patterns. The Adapter Design Pattern.
Design Pattern. The Observer Pattern The Observer Pattern defines a one-to-many dependency between objects so that when one object changes state, all.
Patterns in programming 1. What are patterns? “A design pattern is a general, reusable solution to a commonly occurring problem in software. A design.
Mediator Pattern and Multiuser Protection Billy Bennett June 8 th, 2009.
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
Design Patterns Gang Qian Department of Computer Science University of Central Oklahoma.
Testing Extensible Design Patterns in OO Frameworks through Scenario Templates D.S. Sanders Software Verification & Validation.
Patterns in programming1. 2 What are patterns? Answers to common design problems. A language used by developers –To discuss answers to design problems.
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
CSC 313 – Advanced Programming Topics. What Is the Factory Method?  Creation details hidden by AbstractCreator  Does effective job of limiting concrete.
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.
FACTORY METHOD. Design Pattern Space Purpose ScopeCreationalStructuralBehavioral ClassFactory MethodAdapterInterpreter Template Method ObjectAbstract.
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Object Oriented Analysis & Design Game Patterns. Contents  What patterns are  Delegation  Game Loop  Scene Graph  Double Buffering  Component 
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
Design Patterns Introduction
Introduction to Patterns. Introduction to Patterns Pattern: Webster definition of Pattern: Something regarded as a normative example to be copied.
Design Patterns SE464 Derek Rayside images from NetObjectives.com & Wikipedia.
Threads and Singleton. Threads  The JVM allows multiple “threads of execution”  Essentially separate programs running concurrently in one memory space.
The Strategy Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
CS 325: Software Engineering March 19, 2015 Applying Patterns (Part B) Code Smells The Decorator Pattern The Observer Pattern The Template Method Pattern.
Five Minute Design Patterns Doug Marttila Forest and the Trees May 30, 2009 Template Factory Singleton Iterator Adapter Façade Observer Command Strategy.
Csci 490 / Engr 596 Special Topics / Special Projects Software Design and Scala Programming Spring Semester 2010 Lecture Notes.
FINAL REVIEW. Stronger vs Weaker (one more time!) Requires more? Promises more? (stricter specifications on what the effects entail) weaker stronger.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Factory Method. Intent/Purpose Factory Method is used to deal with a problem of creating objects without specifying the EXACT class of object that we.
1 Creational Design Patterns CSC 335: Object-Oriented Programming and Design.
Patterns in programming
Unit II-Chapter No. : 5- design Patterns
Effective Java Source: Effective Java, Jason Arnold
MPCS – Advanced java Programming
Design Patterns – Chocolate Factory (from Head First Design Patterns)
Factory Patterns 1.
Introduction to Design Patterns
COMP280:Introduction to Software Development Week 10, Lecture 28
Final review CSE331 Winter 2017.
COMP280:Introduction to Software Development, Week 9, Lecture 27
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.
Software Engineering Lecture 7 - Design Patterns
Design Patterns in Game Design
Singleton design pattern
Context Objects Evolution of object behavior Behavioral patterns
Lecture 8 Evolution of object behavior Behavioral patterns
Final review.
CS 325: Software Engineering
Chapter 8, Design Patterns Introduction
Chapter 8, Design Patterns Singleton
Presentation transcript:

1 Design Patterns prepared for COMP314, Bernhard Pfahringer see links on the web page as well!

2 Overview: 3 (4) classes  creational: e.g. singleton, factory, …  structural: e.g. adapter, decorator  behavioural: e.g. visitor, observer, strategy  [concurrency: e.g. locks, thread pool]

3 Singleton  see online code example plus Wikipedia link

4 (Static) Factory (method) public static Boolean valueOf(boolean b) { return b ? Boolean.TRUE : Boolean.FALSE; } +: can use arbitrary but appropriate name: BigInteger.probablyPrime(int,Random) instead of new BigInteger(int,int,Random) +: need not generate a new object +: can return subtype (see Collections) -: no sub-classing (must use composition) -: constructors stand out, factory does not

5 Abstract factories  takes factories one step further  more flexible  see online link for UML and pasta maker analogy  [Weka ’ s Instance(s) classes should probably rewritten this way]

6 Strategy pattern  replace hardcoded selection of alternatives (if/then/else or switch) with pluggable classes  easy to extend (and remove)  equivalent to C++ function pointers  e.g. Swing LayoutManagers  e.g. data loaders in Weka example

7 Visitor  see online code example plus Wikipedia link