Presentation is loading. Please wait.

Presentation is loading. Please wait.

Object Oriented Software Engineering Chapter 16 and 17 review 2014/06/03.

Similar presentations


Presentation on theme: "Object Oriented Software Engineering Chapter 16 and 17 review 2014/06/03."— Presentation transcript:

1 Object Oriented Software Engineering Chapter 16 and 17 review 2014/06/03

2 Pattern’s both side Good sides: help management way Downsides: going to create more class with don’t know.

3 3 categories Creational Structural Behavioral There are more than 23 pattern: MVC…

4 Copyright {c} 2014 by the McGraw-Hill Companies, Inc. All rights Reserved. 16-4 Situation Specific Patterns Creational Patterns Abstract factory Builder Factory method Prototype Singleton Structural Patterns Adapter Bridge Composite Decorator Facade Flyweight Proxy Behavioral Patterns Chain of responsibility Command Interpreter Iterator Mediator Memento Observer State Strategy Template method Visitor

5 I. Creational 1. abstract factory Many family of codes can categories into many categories. E.g. two family belong to factory and the output is produce product. 16-5

6 I. Creational 2. builder To build sth or construct sth which is complex and compose tiny product. Combine product into one and process is similar When client request, director get request, each builder build one product which compose many tiny product.

7 I. Creational 3. factory method Group product into one Based on parameter/ type Client ask give me “cat”(parameter) Same parameter will get same product Animal CatDog

8 I. Creational 3. prototype Refer to original one to build Construction is complex; therefore; don’t build from beginning(mean build only once.) Help change/ want to make change 1.Shallow clone: same as original, new and original both change. 2.Deep clone: create prototype, clone all relationship. New change & keep original(copy on write)

9 I. Creational 4. singleton Create thing at most one (0…1) Make sth Do sth 1.Abstract factory’s sub class could be singleton 2.Combine with Builder 3.Combine with template

10 II. Structural 1. adapter Often see adapter in the world We need data from system, but format will be different. We need to create new interface to extract existing system and combine with user. Adapter make system compatible Class adapter: only one Object adapter: more than one, flexible

11 II. Structural 2. bridge Both side(abstract & implementation) to communicate each other Choose which one to implement == choose which one to marry

12 II. Structural 3. composite We want to compose sth Leaf: terminal and smallness one Component: has leaf Composite: has instance Data structure: recursive, combine Know how to decompose

13 II. Structural 5. decorator Decorate something we have based/plain/no decoration class, and want to put sth on it. Flexible to add sth we need on it Decorator is abstract Component is interface http://puremonkey2010.blogspot.tw/2010/11/oo- decorator-pattern.html http://puremonkey2010.blogspot.tw/2010/11/oo- decorator-pattern.html

14 II. Structural 5. façade Singleton Know each component will feedback to you

15 II. Structural 6. flyweight You need to create 1000 object(all the same) Check out the pool(unique in pool) Intrinsic(constant): save in memory, reuse many times Extrinsic: we will not save.(at client…) stateless

16 II. Structural 7. proxy Surrogate of real one, take place of real one. Representative of real one, in place of real one Placeholder Purpose: 1.Protect: need to know user(define first) to authorize, give key to user 2.Virtual proxy: consume a lot of time, if request yes→ display, no→create 3.Remote proxy:SOA 4.Smart proxy: when user want to access sth, count how many times real one is asked, if nobody ask then free the memory.

17 III. Behavioral 1. chain of responsibility Naming is important Each component on chain have responsibility to do sth Define first one and successor(predecessor) E.g. We have 5 handler on chain, give one problem for them, pass the problem until solve problem, other is exception. Our design not be solve all problem.

18 III. Behavioral 2. command Create sth and object behave Invoker group all command Command execute, if is receiver A, go with A Undo command(not unlimited)

19 III. Behavioral 3. interpreter Have rule, grammar to perform sth We can get data based on grammar Input> rule: parse / segment / format analyze > output

20 III. Behavioral 4. iterator Traverse sth, want to display or save in different Database We don’t want to expose structure, but we want to do structure Template: if you have next one, then do sth.

21 III. Behavioral 5. mediator Coordinator to reduce communication E.g. stock market Observer: stock market change, notify user

22 III. Behavioral 6. memento We have object when someone need previous versions, ask caretaker to get Originator Memento

23 III. Behavioral 7. observer Subject is a content, observer subscribe sth. Many observer interesting one target(1..many) Object change, notify subscriber Reactor design pattern: (*…*) (many…many)

24 III. Behavioral 8. state Class is active, many status define next state

25 III. Behavioral 9. strategy Client can select strategy same text different encryption(algorithm perform differently)

26 III. Behavioral 10.template method Boil> Fried Don’t call us, we’ll can you(hollywood principle)

27 III. Behavioral 11.visitor Knock your door, don’t expose structure. Use iterator to traverse different structure Composite: to segment leaf(knock the leaf) If you have lot of operation differently High cohesion Want to format sth, display it

28 16-28 Process for Applying Patterns

29 16-29 Case Study: Design a State Diagram Editor

30 reference 16-30


Download ppt "Object Oriented Software Engineering Chapter 16 and 17 review 2014/06/03."

Similar presentations


Ads by Google