July 28, 2015IAT 2651 Design Patterns. “Gang of Four” July 28, 2015IAT 2652.

Slides:



Advertisements
Similar presentations
Design Patterns.
Advertisements

Design Patterns Pepper. Find Patterns Gang of Four created 23 Siemens published another good set x
Design Patterns Section 7.1 (JIA’s) Section (till page 259) (JIA’s) Section 7.2.2(JIA’s) Section (JIA’s)
March Ron McFadyen1 Design Patterns In software engineering, a design pattern is a generally repeatable solution to a commonly-occurring problem.
Plab – Tirgul 12 Design Patterns
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 CS is not simply about programming
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.
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
Satzinger, Jackson, and Burd Object-Orieneted Analysis & Design
Fall 2009ACS-3913 R McFadyen1 Singleton Problem: Exactly one instance of a certain object is required (this object is called a singleton). We must ensure.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Design Patterns.
Design Patterns Module Name - Object Oriented Modeling By Archana Munnangi S R Kumar Utkarsh Batwal ( ) ( ) ( )
Chapter 3.4 Programming Fundamentals. 2 Data Structures Arrays – Elements are adjacent in memory (great cache consistency) – They never grow or get reallocated.
Design Patterns Ref : Chapter 15 Bennett et al. useful groups of collaborating classes that provide a solution to commonly occuring problems. provide.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
(c) University of Washington03-1 CSC 143 Java Inheritance Reading: Ch. 10.
1 PH Chapter 1 (pp. 1-10) GoF Composite Pattern (pp ) PH Ch 2 through Fundamentals (pp ) Presentation by Julie Betlach 5/28/2009.
Design Patterns.
Implementing Design Patterns Using Java St. Louis Java Special Interest Group Eric M. Burke Object Computing, Inc. Presented on July 9, 1998 (updated July.
1 Java Inheritance. 2 Inheritance On the surface, inheritance is a code re-use issue. –we can extend code that is already written in a manageable manner.
Advanced Programming Rabie A. Ramadan 7.
Software Engineering 1 Object-oriented Analysis and Design Applying UML and Patterns An Introduction to Object-oriented Analysis and Design and Iterative.
DaveAndAl.net Do Application Design Patterns Make Sense in ASP.NET? Alex Homer You may like to write these down now...
Software Design Patterns (2) four commonly used design patterns using php (singleton, factory, adapter & decorator)
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.
CPSC 372 John D. McGregor Module 4 Session 1 Design Patterns.
L11-12: Design Patterns Definition Iterator (L4: Inheritance)‏ Factory (L4: Inheritance)‏ Strategy (L5: Multiple Inheritance)‏ Composite (L6: Implementation.
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
Design Patterns CS 124 Reference: Gamma et al (“Gang-of-4”), Design Patterns.
Singleton and Basic UML CS340100, NTHU Yoshi. What is UML Unified Modeling Language A standardized general-purpose modeling language in the field of software.
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.
CS 4233 Review Feb February Review2 Outline  Previous Business – My.wpi.edu contains all grades to date for course – Review and contact.
CSC 480 Software Engineering Design With Patterns.
Design Pattern. Definition: A design pattern is a general reusable solution to a commonly occurring problem within a given context in software design.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Gang of Four Patterns 23 total 15 useful How are they different from GRASP Patterns?
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
CS212: Object Oriented Analysis and Design Lecture 38: Design Pattern-II.
Design Patterns Introduction
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
Patterns in programming
Design Patterns: MORE Examples
MPCS – Advanced java Programming
Introduction to Design Patterns
Design Patterns Based on slides provided by Abbie Jarrett
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 in Operating Systems
Chapter 10 Thinking in Objects
Advanced Programming Behnam Hatami Fall 2017.
Software Engineering Lecture 7 - Design Patterns
Design Patterns in Game Design
08/15/09 Design Patterns James Brucker.
Frameworks And Patterns
Object Oriented Design Patterns - Creational Patterns
Object Oriented Design Patterns - Behavioral Patterns
What is Singleton Category: Creational pattern
Singleton Pattern Pattern Name: Singleton Pattern Context
Singleton design pattern
CS 350 – Software Design Singleton – Chapter 21
Software Design Patterns (2)
Design Patterns Imran Rashid CTO at ManiWeber Technologies.
Chapter 8, Design Patterns Singleton
Presentation transcript:

July 28, 2015IAT 2651 Design Patterns

“Gang of Four” July 28, 2015IAT 2652

Design Advice  Program to an Interface, not an implementation  Composition over Inheritance –Build software by composing objects together –Inheritance is often difficult to manage Changes to parent class may mess up child classes July 28, 2015IAT 2653

Interface  If you write code to implement an interface –There is no possibility for parent changes to mess up child classes –Unfortunately, you can’t re-use code via inheritance July 28, 2015IAT 2654

Balance Inheritance  Inheritance is useful where: –There is a strong IS-A relationship –Child class uses all of parent data –Child class does a lot of the same stuff the parent does  Not so good if –Child class ignores a lot of parent data –Child class adds new behaviors and ignores old behaviors July 28, 2015IAT 2655

Design Advice  As with any design problem  It is Rarely the case that the first design is the best  As with any design task, be prepared to do it over July 28, 2015IAT 2656

Design Patterns  The Gang of Four offer the following design patterns, in 3 categories: –Creational Patterns: Patterns of objects that are about creating objects –Structural Patterns: Patterns of composing objects together –Behavioral: Patterns of communication between objects July 28, 2015IAT 2657

Creational: Factory  Factory method –a method in some class generates an instance of a class -- NOT a constructor! class ArmedRocket extends Rocket {... Missile fire() { Missile m = new Missile(xPos, yPos, rotation); return m; } July 28, 2015IAT 2658

Singleton pattern  Make only 1 instance of an object: Ever!  Useful when: there’s some single resource or state you want to manage public class SingletonDemo { private static SingletonDemo instance; private SingletonDemo() { } public static SingletonDemo getInstance() { if (instance == null ) { instance = new SingletonDemo(); } return instance; } July 28, 2015IAT 2659

Behavioral Patterns  Iterator  Provide a way to access the elements of an aggregate object (container, list) without exposing its underlying implemetation  In Java, it’s the Iterator interface Iterator itr = al.iterator(); while(itr.hasNext()) { Object element = itr.next(); } July 28, 2015IAT 26510

Observer  A Subject –Maintains a list of observers, and notifies them whenever subject’s state changes  Used in almost every GUI toolkit/widget set –Slider “Observes” mouse events in its region  Also fundamental to CPU architecture as the Interrupt Service Routine July 28, 2015IAT 26511