+ All Categories
Home > Documents > Object Oriented Software Engineering Chapter 16 and 17 review 2014/06/03.

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

Date post: 04-Jan-2016
Category:
Upload: barnaby-berry
View: 212 times
Download: 0 times
Share this document with a friend
30
Object Oriented Software Engineering Chapter 16 and 17 review 2014/06/03
Transcript
Page 1: Object Oriented Software Engineering Chapter 16 and 17 review 2014/06/03.

Object Oriented Software Engineering

Chapter 16 and 17 review2014/06/03

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

Pattern’s both side

• Good sides: help management way• Downsides: going to create more class with

don’t know.

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

3 categories

• Creational • Structural • Behavioral

There are more than 23 pattern: MVC…

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

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

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

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

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

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.

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

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

Cat Dog

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

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 change1. 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)

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

I. Creational 4. singleton

• Create thing at most one (0…1)• Make sth • Do sth

1. Abstract factory’s sub class could be singleton2. Combine with Builder 3. Combine with template

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

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

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

II. Structural 2. bridge

• Both side(abstract & implementation) to communicate each other

• Choose which one to implement ==choose which one to marry

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

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

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

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

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

II. Structural 5. façade

• Singleton• Know each component will feedback to you

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

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

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

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 user2. Virtual proxy: consume a lot of time, if request yes→ display,

no→create3. Remote proxy:SOA4. Smart proxy: when user want to access sth, count how many

times real one is asked, if nobody ask then free the memory.

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

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.

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

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)

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

III. Behavioral 3. interpreter

• Have rule, grammar to perform sth• We can get data based on grammar• Input>

rule: parse / segment / format analyze> output

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

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.

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

III. Behavioral 5. mediator

• Coordinator to reduce communication• E.g. stock market• Observer: stock market change, notify user

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

III. Behavioral 6. memento

• We have object• when someone need previous versions, ask

caretaker to get• Originator• Memento

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

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)

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

III. Behavioral 8. state

• Class is active, many status define next state

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

III. Behavioral 9. strategy

• Client can select strategy same text different encryption(algorithm perform differently)

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

III. Behavioral 10.template method

• Boil> Fried• Don’t call us , we’ll can you(hollywood

principle)

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

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

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

16-28

Process for Applying Patterns

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

16-29

Case Study: Design a State Diagram Editor

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

reference

16-30


Recommended