Design Principle & Patterns by A.Surasit Samaisut Copyrights 2009-2010 : All Rights Reserved.

Slides:



Advertisements
Similar presentations
Ch:8 Design Concepts S.W Design should have following quality attribute: Functionality Usability Reliability Performance Supportability (extensibility,
Advertisements

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.
Design Patterns Section 7.1 (JIA’s) Section (till page 259) (JIA’s) Section 7.2.2(JIA’s) Section (JIA’s)
Basic Concepts in Component-Based Software Engineering
Plab – Tirgul 12 Design Patterns
Dept. of Computer Engineering, Amirkabir University of Tech. 1 Design Patterns Dr. Noorhosseini Introduction.
Design Patterns CS is not simply about programming
Copyright © Active Frameworks, Inc.. - All Rights Reserved - V2.0 Introduction - Page L1-1 PS95&96-MEF-L1-1 Dr. M.E. Fayad Creationa l Paradigm.
DESIGN PATTERNS Redesigning Applications And
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 ( ) ( ) ( )
Design Patterns Ref : Chapter 15 Bennett et al. useful groups of collaborating classes that provide a solution to commonly occuring problems. provide.
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
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.
Design Patterns Discussion of pages: xi-11 Sections: Preface, Forward, Chapter
Design Patterns.
Design Patterns OOD. Course topics Design Principles UML –Class Diagrams –Sequence Diagrams Design Patterns C#,.NET (all the course examples) Design Principles.
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.
Design Patterns: Introduction. Creational Design Patterns General and reusable solutions to common problems in software design Software University
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
CSSE 374: Introduction to Gang of Four Design Patterns
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
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.
Powerpoint Templates Page 1 Powerpoint Templates What is Design Patterns ? by Indriati Teknik Informatika – UB.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 27. Review UML dynamic view – State Diagrams.
Drexel University CS 451 Software Engineering Winter Yuanfang Cai Room 104, University Crossings
Object-Oriented Design Principles and Patterns. © 2005, James R. Vallino2 How Do You Design? What principles guide you when you create a design? What.
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
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.
Design Patterns Introduction General and reusable solutions to common problems in software design SoftUni Team Software University
ECE450S – Software Engineering II
Understanding and using patterns in software development EEL 6883 Software Engineering Vol. 1 Chapter 4 pp Presenter: Sorosh Olamaei.
Design Patterns -- Omkar. Introduction  When do we use design patterns  Uses of design patterns  Classification of design patterns  Creational design.
CSC 480 Software Engineering Design With Patterns.
Programmeerimine Delphi keskkonnas MTAT Programmeerimine Delphi keskkonnas MTAT Jelena Zaitseva
Copyright © Active Frameworks Inc. - All Rights Reserved - V2.0Design Pattern Catalog - Page L3-1 PS95&96-MEF-L10-1 Dr. M.E. Fayad Creationa.
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.
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
Design Patterns Introduction
1 Chapter 5:Design Patterns. 2 What are design pattern?  Schematic description of design solution to recurring problems in software design and,  Reusable.
Design Patterns Introduction “Patterns are discovered, not invented” Richard Helm.
Advanced Object-oriented Design Patterns Creational Design Patterns.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 5th Edition Copyright © 2015 John Wiley & Sons, Inc. All rights.
Overview of Creational Patterns ©SoftMoore ConsultingSlide 1.
Class Relationships Lecture Oo08 Polymorphism. References n Booch, et al, The Unified Modeling Language User Guide, Chapt 10 p.125 n Fowler & Scott, UML.
1 Good Object-Oriented Design Dr. Radu Marinescu Lecture 4 Introduction to Design Patterns.
1 Design Patterns G.Ramesh Babu. © Bennett, McRobb and Farmer In This Lecture You Will Learn:  What types of patterns have been identified in.
Basic Characteristics of Object-Oriented Systems
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
GRASP – Designing Objects with Responsibilities
Design Patterns: MORE Examples
Design Patterns: Brief Examples
Chapter 10 Design Patterns.
Chapter 5:Design Patterns
Software Design Patterns
MPCS – Advanced java Programming
Introduction to Design Patterns
Introduction to Design Patterns
Design Patterns.
Software Engineering Lecture 7 - Design Patterns
Patterns.
DESIGN PATTERNS : Introduction
Informatics 122 Software Design II
Software Design Lecture : 27.
Presentation transcript:

Design Principle & Patterns by A.Surasit Samaisut Copyrights : All Rights Reserved

Page  2 Recurring Design Purposes Requirements Analysis Framework Design Architecture Design Detailed Design Implementation

Page  3 What is Design Patterns  Is a general reusable solution to a commonly occurring problem in software design  Is not a finished design that can be transformed directly into code  Is a description or template for how to solve a problem that can be used in many different situations  Object-oriented design patterns typically show relationships and interactions between classes or objects, without specifying the final application classes or objects that are involved

Page  4 What is Design Patterns  a standard solution to a common programming problem  a technique for making code more flexible by meet certain criteria  a design or implementation structure that achieves a particular purpose  a high-level programming idiom  shorthand for describing certain aspects of program organization  connections among program components and is the shape of a heap snapshot or object model

Page  5 What is Design Patterns  A pattern is a named abstraction from a concrete form that represents a recurring solution to a particular problem  Patterns = problem/solution pairs in context  Patterns facilitate reuse of successful software architectures and design  Not code reuse Instead, solution/strategy reuse Sometimes, interface reuse “Patterns are discovered, not invented” - Richard Helm

Page  6 What is Design Patterns  Design patterns reside in the domain of modules and interconnections. At a higher level there are Architectural patterns which are larger in scope, usually describing an overall pattern followed by an entire system  Not all software patterns are design patterns. For instance, algorithms solve computational problems rather than software design problems

Page  7 Modern Origin of Design Patterns “Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice” [Christopher Alexander et al., A Pattern Language: Towns, Buildings, Construction. Oxford University Press,1977]

Page  8 Purpose of Design Patterns  A design pattern captures design expertise – patterns are not created from thin air, but abstracted from existing design examples  Using design patterns is reuse of design expertise  Studying design patterns is a way of studying how the “experts” do design

Page  9 Structure of a Pattern  Pattern description should include: Name: should be meaningful Problem: a description of the problem the pattern addresses Context: preconditions under which it can occur Forces: constraints/issues the solution must address Solution: description of static and dynamic relationships among the components of the pattern –A solution should resolve the forces in the given context Plus –Example of use –Related patterns, List of aliases for the pattern –Sample code

Page  10 Patterns = Good Design  Software design patterns are supposed to embody good design practice Abstraction Encapsulation Information hiding Modularisation Separation of concerns High internal cohesion and low external coupling Sufficiency, completeness and primitiveness Separation of policy and implementation Single point of reference Divide and conquer

Page  11 Patterns and Non-Functional Requirements  Patterns are also meant to enhance important nonfunctional properties of the system Changeability Interoperability Efficiency Reliability Testability Reusability

Page  12 Design Patterns – In Practice  Design patterns can speed up the development process by providing tested, proven development paradigms  Effective software design requires considering issues that may not become visible until later in the implementation. Reusing design patterns helps to prevent subtle issues that can cause major problems, and it also improves code readability for coders and architects who are familiar with the patterns

Page  13 Categories of Patterns  Design patterns vary in granularity and level of abstraction  By categorizing patterns, it becomes easier to recognize and learn them  Categorized by purpose or scope Purpose reflects what the pattern does Scope specifies if the pattern applies to classes or objects

Page  14 Categories of Patterns  Purpose Creational patterns Structural patterns Behavioral patterns  Scope –Class Patterns: »Deal with relationships between classes or subclasses established through inheritance »These relationships are fixed at compile time –Objects patterns: »Deal with object relationships that can be changed at runtime

Page  15 Categories of Patterns Patterns PurposeScope Behavioral patterns Creational patterns Structural patterns Class patterns Objects patterns

Page  16 How do Design Patterns Solve Design Problems?  The meaning of OO is well-known  The hard part is decomposing the system into objects to exploit: Encapsulation Flexibility, extensibility Ease of modification Performance Evolution Reusability

Page  17 Benefits of Patterns  Shared language of design Increases communication bandwidth Decreases misunderstandings  Learn from experience Becoming a good designer is hard –Understanding good designs is a first step Tested solutions to common problems –Where is the solution applicable? –What are the tradeoffs?

Page  18 Type of Design Pattern  Gamma et al [Ga] have classified each of the design patterns in one of three categories, depending upon whether it has to do with Creational patterns (constructing objects) –Creating a collection of objects in flexible ways Structural patterns (controlling heap layout) –Representing a collection of related objects Behavioral patterns (affecting object semantics) –Capturing behavior among a collection of objects

Page  19 Creational Design Patterns  Creational design patterns help us to design applications involving collections of objects: they allow the creation of several possible collections from a single block of code, but with properties such as Creating many versions of the collection at runtimes Constraining the objects created: for example, ensuring that there is only instance of its class  Concept: create objects in flexible or constrained ways

Page  20 Creational Design Patterns  Concerned with construction of object instances  Separate the operations of an application from the creation of objects  Added flexibility in configuring all aspects of creation Static (compile-time) Dynamic (run-time)

Page  21 Creational Design Patterns  Abstract Factory: Provide an interface for creating families of related or dependent objects without specifying their concrete classes  Builder: Separate construction of a complex object from its representation so that the same construction process can create different representations  Factory Method: Define an interface for creating an object, but let subclasses decide which class to instantiate. The Factory Method lets a class defer instantiation to subclasses

Page  22 Creational Design Patterns  Prototype: Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype  Singleton: Ensure that a class only has one instance, and provide a global point of access to it

Page  23 Creational Design – Singleton Pattern  Problem: How can one design a class that should have only one instance and that can be accessed globally within the application?  Context: In some applications it is important for a class to have exactly one instance. A sales order processing application may be dealing with sales for one company. It is necessary to have a Company object that holds details of the company. Clearly there should only be one such object.  Forces: One approach to making an object globally accessible is to make it a global variable, but this is not good design solution. Another way is not to create an object instance at all but to use only static methods. However this is not extensible to situations when it is desirable to exploit polymorphism on singleton subclasses.

Page  24 Creational Design – Singleton Pattern  Solution: Create a static method getInstance(). When accessed the first time, it creates the object instance and returns a reference to the created object. On subsequent accesses, no additional instance is created, and the reference to the existing object is returned  Company details stored in a class The constructor is defined private to the class The constructor is called within a public static method of the class that ensures only a single object exists

Page  25 Creational Design – Singleton Pattern  Clients call the public method to access the object public class Company { private static Company companyInstance; private Company() { … } public static Company getCompanyInstance(){ if (companyInstance == null) { companyInstance=new Company(); } return companyInstance; } Company.getCompanyInstance().CompanyMethod(…)

Page  26 Structural Design Patterns  Structural design patterns help us to arrange collections of objects in forms such as linked lists or trees.  Concept: represent data structures such as trees with uniform processing interfaces

Page  27 Behavioral Design Patterns  Each behavioral pattern captures a kind of behavior among a collection of objects  Concept: we want to be able to use classes in other applications