Presentation is loading. Please wait.

Presentation is loading. Please wait.

Powerpoint Templates Page 1 Powerpoint Templates What is Design Patterns ? by Indriati Teknik Informatika – UB.

Similar presentations


Presentation on theme: "Powerpoint Templates Page 1 Powerpoint Templates What is Design Patterns ? by Indriati Teknik Informatika – UB."— Presentation transcript:

1 Powerpoint Templates Page 1 Powerpoint Templates What is Design Patterns ? by Indriati Teknik Informatika – UB

2 Powerpoint Templates Page 2 Outline Background Pattern origins and history Definition Elements of Design Patterns Desing Patterns are NOT Where Design Patterns are used Describing Design Patterns Types of patterns

3 Powerpoint Templates Page 3 Background 1 Search for recurring successful designs – emergent designs from practice (via trial and error) Supporting higher levels of reuse (i.e., reuse of designs) is quite challenging Described in Gama, Helm, Johnson, Vlissides 1995 (i.e., “gang of 4 book”) Based on work by Christopher Alexander (an Architect) on building homes, buildings and towns.

4 Powerpoint Templates Page 4 Background 2 Design patterns represent solutions to problems that arise when developing software within a particular context. E.g., problem/solution pairs within a given context Describes recurring design structures Describes the context of usage

5 Powerpoint Templates Page 5 Background 3 Patterns capture the static and dynamic structure and collaboration among key participants in software designs Especially good for describing how and why to resolve nonfunctional issues Patterns facilitate reuse of successful software architectures and designs.

6 Powerpoint Templates Page 6 Pattern origins and history writings of architect Christopher Alexander (coined this use of the term "pattern" ca. 1977-1979) Kent Beck and Ward Cunningham, Textronix, OOPSLA'87 (used Alexander's "pattern" ideas for Smalltalk GUI design) Erich Gamma, Ph. D. thesis, 1988-1991 James Coplien, Advanced C++ Idioms book, 1989-1991 ("Gang of Four“ - GoF)Gamma, Helm, Johnson, Vlissides ("Gang of Four“ - GoF) Design Patterns: Elements of Reusable Object-Oriented Software, 1991-1994 PLoP Conferences and books, 1994-present (“POSA book”)Buschmann, Meunier, Rohnert, Sommerland, Stal, Pattern -Oriented Software Architecture: A System of Patterns (“POSA book”)

7 Powerpoint Templates Page 7 Definition … a fully realized form, original, or model accepted or proposed for imitation…[dictionary]... 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 [Alexander]

8 Powerpoint Templates Page 8 Definition a design pattern is a general reusable solution to a commonly occurring problem in software design. A design pattern is not a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations. [Wikipedia]

9 Powerpoint Templates Page 9 Definition … the abstraction from a concrete form which keeps recurring in specific non-arbitrary contexts [Riehle] …both a thing and the instructions for making the thing [Coplien]...a literary format for capturing the wisdom and experience of expert designers, and communicating it to novices

10 Powerpoint Templates Page 10 Elements of Design Patterns Design patterns have four essential elements: –Pattern name –Problem –Solution –Consequences

11 Powerpoint Templates Page 11 Pattern Name A handle used to describe: –a design problem –its solutions –its consequences Increases design vocabulary Makes it possible to design at a higher level of abstraction Enhances communication “The Hardest part of programming is coming up with good variable [function, and type] names.”

12 Powerpoint Templates Page 12 Problem Describes when to apply the pattern Explains the problem and its context May describe specific design problems and/or object structures May contain a list of preconditions that must be met before it makes sense to apply the pattern

13 Powerpoint Templates Page 13 Solution Describes the elements that make up the –design –relationships –responsibilities –collaborations Does not describe specific concrete implementation Abstract description of design problems and how the pattern solves it

14 Powerpoint Templates Page 14 Consequences Results and trade-offs of applying the pattern Critical for: –evaluating design alternatives –understanding costs –understanding benefits of applying the pattern Includes the impacts of a pattern on a system’s: –flexibility –extensibility –portability

15 Powerpoint Templates Page 15 Design Patterns are NOT Designs that can be encoded in classes and reused as is (i.e., linked lists, hash tables) Complex domain-specific designs (for an entire application or subsystem) They are: –“Descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context.”

16 Powerpoint Templates Page 16 Where They are Used Object-Oriented programming languages [and paradigm] are more amenable to implementing design patterns Procedural languages: need to define –Inheritance –Polymorphism –Encapsulation

17 Powerpoint Templates Page 17 Describing Design Patterns Graphical notation is generally not sufficient In order to reuse design decisions the alternatives and trade-offs that led to the decisions are critical knowledge Concrete examples are also important The history of the why, when, and how set the stage for the context of usage

18 Powerpoint Templates Page 18 Design Patterns Describe a recurring design structure –Defines a common vocabulary –Abstracts from concrete designs –Identifies classes, collaborations, and responsibilities –Describes applicability, trade-offs, and consequences

19 Powerpoint Templates Page 19 Alexandrian form (canonical form) Name meaningful name Problem the statement of the problem Context a situation giving rise to a problem Forces a description of relevant forces and constraints Solution proven solution to the problem Examples sample applications of the pattern

20 Powerpoint Templates Page 20 Alexandrian form (canonical form) Resulting context (force resolution) the state of the system after pattern has been applied Rationale explanation of steps or rules in the pattern Related patterns static and dynamic relationship Known use occurrence of the pattern and its application within existing system

21 Powerpoint Templates Page 21 GoF format Pattern name and classification Intent what does pattern do / when the solution works Also known as other known names of pattern (if any) Motivation the design problem / how class and object structures solve the problem Applicability situations where pattern can be applied Structure a graphical representation of classes in the pattern Participants the classes/objects participating and their responsibilities Collaborations of the participants to carry out responsibilities

22 Powerpoint Templates Page 22 GoF format Consequences trade-offs, concerns Implementation hints, techniques Sample code code fragment showing possible implementation Known uses patterns found in real systems Related patterns closely related patterns

23 Powerpoint Templates Page 23 Types of Patterns Creational patterns: –Deal with initializing and configuring classes and objects Structural patterns: –Deal with decoupling interface and implementation of classes and objects –Composition of classes or objects Behavioral patterns: –Deal with dynamic interactions among societies of classes and objects –How they distribute responsibility

24 Powerpoint Templates Page 24 Creational Patterns Abstract Factory: –Factory for building related objects Builder: –Factory for building complex objects incrementally Factory Method: –Method in a derived class creates associates Prototype: –Factory for cloning new instances from a prototype Singleton: –Factory for a singular (sole) instance

25 Powerpoint Templates Page 25 Structural Patterns Adapter: –Translator adapts a server interface for a client Bridge: –Abstraction for binding one of many implementations Composite: –Structure for building recursive aggregations Decorator: –Decorator extends an object transparently Facade: –Simplifies the interface for a subsystem Flyweight: –Many fine-grained objects shared efficiently. Proxy: –One object approximates another

26 Powerpoint Templates Page 26 Behavioral Patterns Chain of Responsibility: –Request delegated to the responsible service provider Command: –Request is first-class object Iterator: –Aggregate elements are accessed sequentially Interpreter: –Language interpreter for a small grammar Mediator: –Coordinates interactions between its associates Memento: –Snapshot captures and restores object states privately

27 Powerpoint Templates Page 27 Behavioral Patterns (cont.) Observer: –Dependents update automatically when subject changes State: –Object whose behavior depends on its state Strategy: –Abstraction for selecting one of many algorithms Template Method: –Algorithm with some steps supplied by a derived class Visitor: –Operations applied to elements of a heterogeneous object structure

28 Powerpoint Templates Page 28 Design Pattern Space Chain of responsibility Command Iterator Mediator Memento Observer State Strategy Visitor Adapter (object) Bridge Composite Decorator Façade Flyweight Proxy Abstract factory Builder Prototype Singleton Object Interpreter Template method Adapter (class)Factory method ClassScope BehavioralStructuralCreational Purpose

29 Powerpoint Templates Page 29 Categorization Terms Scope is the domain over which a pattern applies –Class Scope: relationships between base classes and their subclasses (static semantics) –Object Scope: relationships between peer objects Some patterns apply to both scopes.

30 Powerpoint Templates Page 30 Class::Creational Abstracts how objects are instantiated Hides specifics of the creation process May want to delay specifying a class name explicitly when instantiating an object Just want a specific protocol

31 Powerpoint Templates Page 31 Assignment Presentation topic 1.Abstract factory+builder 2.Factory Method+prototype+singleton 3.Bridge+ Flyweight 4.Composite+decorator 5.Adapter +Facade+Proxy 6.Command+Chain of responsibility 7.Iterator+Interpreter 8.Memento+mediator 9.Template Method+Strategy 10.Visitor+observer+state 11.Agile Development

32 Powerpoint Templates Page 32 Rules of the class Run in Seminar Style –Each class consists of two or three student presentations of design patterns –Each presentation is followed by a discussion of the material presented Prepare a Power-Point presentation –Description of each type of design pattern –A piece of code to representation the type of design pattern –Demo (optional)

33 Powerpoint Templates Page 33 Deadline: Sept 22, 2010 Email to : indriati.tif@ub.ac.idindriati.tif@ub.ac.id Subject : [ topic ]


Download ppt "Powerpoint Templates Page 1 Powerpoint Templates What is Design Patterns ? by Indriati Teknik Informatika – UB."

Similar presentations


Ads by Google