James Tam Introduction To Design Patterns You will learn about design techniques that have been successfully applied to different scenarios.

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

Introduction To Design Patterns You will learn about design techniques that have been successfully applied to different scenarios.
Design Patterns Yes, they are important Robert Cotton April 23, 2009.
Introduction To System Analysis and Design
05/26/2004www.indyjug.net1 Indy Java User’s Group June Knowledge Services, Inc.
ISYS 512 Business Application Design and Development with.Net David Chao.
Design of Web-based Systems IS Development: lecture 10.
1 SWE Introduction to Software Engineering Lecture 22 – Architectural Design (Chapter 13)
James Tam Introduction To Design Patterns You will learn about design techniques that have been successfully applied to different scenarios.
Satzinger, Jackson, and Burd Object-Orieneted Analysis & Design
OOHDM Hypermedia Research Work Designing Web-based applications with Object Oriented Hypermedia Design Method OOHDM.
Spring 2010CS 2251 Design Patterns. Spring 2010CS 2252 What is a Design Pattern? "a general reusable solution to a commonly occurring problem in software.
Software Engineering I Object-Oriented Design Software Design Refinement Using Design Patterns Instructor: Dr. Hany H. Ammar Dept. of Computer Science.
Adapters Presented By Zachary Dea. Definition A pattern found in class diagrams in which you are able to reuse an ‘adaptee’ class by providing a class,
1 Design patterns Lecture 4. 2 Three Important skills Understanding OO methodology Mastering Java language constructs Recognizing common problems and.
Object-Oriented Analysis and Design
Façade Design Pattern Source: Design Patterns – Elements of Reusable Object- Oriented Software; Gamma, et. al.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Design Patterns academy.zariba.com 1. Lecture Content 1.What are Design Patterns? 2.Creational 3.Structural 4.Behavioral 5.Architectural 6.Design Patterns.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
Builder A Creational Design Pattern A Presentation by Alex Bluhm And.
Introduction To System Analysis and design
Design Patterns Alan Shalloway, James Trott, Design Patterns Explained, Addison-Wesley, Gamma, Helm, Johnson, Vlissides, Design Patterns, Elements.
LAYING OUT THE FOUNDATIONS. OUTLINE Analyze the project from a technical point of view Analyze and choose the architecture for your application Decide.
Microsoft Visual Basic 2005: Reloaded Second Edition
MVC and MVP. References enter.html enter.html
Software Design Refinement Using Design Patterns Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
Implementing Design Patterns Using Java St. Louis Java Special Interest Group Eric M. Burke Object Computing, Inc. Presented on July 9, 1998 (updated July.
Introduction to Design Patterns (1). Definition: “ In software engineering, a design pattern is a general reusable solution to a commonly occurring problem.
M1G Introduction to Database Development 6. Building Applications.
Introduction To System Analysis and Design
ISP666 MVC & Design Patterns. Outline Review Event Programming Model Model-View-Controller Revisit Simple Calculator Break Design Patterns Exercise.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 27. Review UML dynamic view – State Diagrams.
CS 325: Software Engineering February 12, 2015 Applying Responsibility-Assignment Patterns Design Patterns Situation-Specific Patterns Responsibility-Assignment.
James Tam Introduction To Design Patterns You will learn about design techniques that have been successfully applied to different scenarios.
(c) University of Washington08-1 CSC 143 Models and Views Reading: Ch. 18.
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
Mohammed Al-Dhelaan CSci 253 Object Oriented Design Instructor: Brad Taylor 06/02/2009 Factory Method Pattern.
05/26/2004www.indyjug.net1 Indy Java User’s Group May Knowledge Services, Inc.
CS 160: Software Engineering October 22 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Framework for Virtual Web Laboratory I. Petković M. Rajković.
Concordia University Department of Computer Science and Software Engineering Click to edit Master title style ADVANCED PROGRAMMING PRACTICES Model View.
Architecture, Design Patterns and Faithful Implementation David Woollard University of Southern California Software Architecture Group NASA Jet Propulsion.
Seung Ha.  Façade is generally one side of the exterior of a building, especially the front.  Meaning “frontage” or “face”  In software architecture,
Java Programming, 3e Concepts and Techniques Chapter 1 Section 56 – An Introduction to Java.
A Presentation Presentation On JSP On JSP & Online Shopping Cart Online Shopping Cart.
Your Interactive Guide to the Digital World Discovering Computers 2012 Chapter 13 Computer Programs and Programming Languages.
Presented by Alexey Vedishchev Developing Web-applications with Grails framework American University of Nigeria, 2016 Intro To MVC Architecture.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
Introduction To Design Patterns
Design Patterns Source: “Design Patterns”, Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides And Created.
Software Design Refinement Using Design Patterns
The Object-Oriented Thought Process Chapter 15
MPCS – Advanced java Programming
Design Patterns Introduction
Design Patterns Damian Gordon.
Introduction To Design Patterns
Advanced Programming Behnam Hatami Fall 2017.
Model-View-Controller Patterns and Frameworks
08/15/09 Design Patterns James Brucker.
DESIGN PATTERNS : Introduction
Advanced ProgramMING Practices
Design Patterns Imran Rashid CTO at ManiWeber Technologies.
Advanced ProgramMING Practices
Introduction To Design Patterns
Introduction To Design Patterns
Presentation transcript:

James Tam Introduction To Design Patterns You will learn about design techniques that have been successfully applied to different scenarios.

James Tam What Is A Design Pattern? A general and reusable solution to a commonly occurring problem in the design of software. IT IS NOT a finished algorithm that can be directly translated into program code. IT IS a template for how to solve a problem that has been used in many different situations. Object-Oriented design patterns show interactions between classes and objects without the specific the program code that implements the pattern.

James Tam Origin Of Design Patterns The foundation for design patterns come from the original patterns specified in the book “ Design Patterns: Elements of Reusable Object-Oriented Software ” Authors: “The gang of four” (Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides). Although examples of the patterns were provided in C++ and SmallTalk the patterns can be applied to any Object- Oriented language.

James Tam The Model-View-Controller Pattern 1 Sometimes the same data may have to be accessed under different contexts e.g., powerful desktop, web, mobile device. Each context may require a different interface (e.g., web page on a mobile device, software on a computer). Even within an interface there may be a desire to see different views of the data e.g., financial analysts may want to see details (spreadsheet and/or financial statement) whereas the shareholders or management may focus on overview views (graphs) 1 Some additional sources that describe the model-view controller pattern: I.Sun Microsystems: II.Microsoft:

James Tam The Model-View-Controller Pattern 1 With this pattern the logic required to maintain the data is separated (database, text file) from how the data is viewed (graph, numerical) vs. how the data can be interacted with (GUI, command line). Model State (data) View Display of data Interface Controller Event handling State change State query Change notification User interaction View selection

James Tam Model-View Controller Pattern (2) With many client applications the view and the controller may be viewed as one entity. With web-based applications the view and the controller may be very well defined: –View: client browser program –Controller: the server side applications that handle the web requests

James Tam Model-View-Controller Pattern (3) Implementing different parts that are decoupled (minimized dependencies) provides many benefits: –One part may be changed independent of the other parts e.g., updates to the interface can have minimal impact on the data. –It’s seldom that one person will have a deep understanding of all parts (e.g., knowledge of Accounting to create the financial statements vs. knowledge of web design to create the web interface). Different people with different areas of expertise can work on the different parts. –One version of the data can be created and maintained and as needed different ways of interacting and viewing data can be developed.

James Tam The Strategy Pattern The algorithm is determined at run time. Chess algorithms Knight’s tour King gambit Bishop pair Computer fighting style: sparring simulation Boxing Tai chi Savate

James Tam The Strategy Pattern (2) One object contains a reference to another object. The second object determines the algorithm to execute.

James Tam The Strategy Algorithm: Example The complete online example can be found in UNIX under: /home/233/examples/designPatterns/strategy public class Driver { public static void main (String [] args) { MyContainer aContainer = null; // First algorithm aContainer = new MyContainer (new AddAlgorithm()); System.out.println(aContainer.executeAlgorithm(2,5)); // Second algorithm aContainer = new MyContainer (new MultiplyAlgorithm()); System.out.println(aContainer.executeAlgorithm(2,5)); }

James Tam The Strategy Algorithm: An Example (2) public class MyContainer { private Algorithm anAlgorithm; public MyContainer (Algorithm anAlgorithm) { this.anAlgorithm = anAlgorithm; } public int executeAlgorithm (int x, int y) { return(anAlgorithm.execute(x,y)); }

James Tam The Strategy Algorithm: An Example (3) public interface Algorithm { public int execute (int x, int y); } public class AddAlgorithm implements Algorithm { public int execute (int x, int y) { return (x+y); } public class MultiplyAlgorithm implements Algorithm { public int execute (int x, int y) { return (x*y); }

James Tam Advantages Of The Strategy Pattern It decouples the context/container from the algorithm used by the context/container. –For the container it may allow the context/container to easily substitute additional algorithms. –For the algorithm, the algorithm may be used in a number of different contexts/containers (e.g., sorting algorithms).

James Tam You Should Now Know What is a design pattern How two example design patterns work