Design Overview Design Overview Ch 6 w w

  • Slides: 20
Download presentation
Design Overview ¨ Design Overview (Ch 6) w w ¨ (Global) System Design (Ch

Design Overview ¨ Design Overview (Ch 6) w w ¨ (Global) System Design (Ch 7) w w ¨ Review of RAD System Design Concepts System Design Goals Software Architecture Boundary Use Cases SDD Subsystem Design w Patterns (Ch 8) w Interfaces (Ch 9) w Mapping to Code (Ch 10) COP 3331 Object-Oriented Analysis and Design 1

Re-Use ¨ Design Patterns w Adapter, Bridge w Strategy, Command, Composite w Abstract Factory

Re-Use ¨ Design Patterns w Adapter, Bridge w Strategy, Command, Composite w Abstract Factory ¨ Frameworks w w ¨ Infrastructure Middleware Application Whitebox / Blackbox Libraries w Domain neutral w Independent and fine grain w Control passive ¨ Components w Predefined instances (pre-compiled code) w Not modifiable COP 3331 Object-Oriented Analysis and Design 2

Inheritance ¨ Specification inheritance (recommended) w w ¨ Interface inheritance Re-use interface Create a

Inheritance ¨ Specification inheritance (recommended) w w ¨ Interface inheritance Re-use interface Create a subtype Example (from 3330): vehicle / truck / tanker Implementation inheritance (use with caution) w Re-use (implementation) code w Example: List / Ordered. List w Problems: t Not extensible (hard to change the implementation) t Not a subtype: can’t substitute for base class w C++ private inheritance overcomes subtype issue ¨ Liskov Substitution Principle (LSP) w Definition: S is a subtype of T iff an object of type S can be substituted whenever an object of type T is expected w Principle: Use inheritance only for subtyping COP 3331 Object-Oriented Analysis and Design 3

Delegation ¨ ¨ Preferred for code reuse Extensible: facilitates change of implementation Does not

Delegation ¨ ¨ Preferred for code reuse Extensible: facilitates change of implementation Does not create a false supertype Delegation and Inheritance work together in design patterns COP 3331 Object-Oriented Analysis and Design 4

Design Patterns ¨ Name w Uniquely identifies pattern w Evokes details to designer ¨

Design Patterns ¨ Name w Uniquely identifies pattern w Evokes details to designer ¨ Problem description w Describes situations appropriate for using the pattern w Usually includes modifiability, extensibility, and nonfunctional design goals ¨ Solution w State as a set of collaborating entities (mostly classes and objects) w Typically includes an illustration ¨ Consequences w Describe the trade-offs and alternatives with respect to the design goals being addressed COP 3331 Object-Oriented Analysis and Design 5

Adaptor [A. 2] Client. Interface Legacy. Class Request() Existing. Request() adaptee Adapter Request() COP

Adaptor [A. 2] Client. Interface Legacy. Class Request() Existing. Request() adaptee Adapter Request() COP 3331 Object-Oriented Analysis and Design 6

Adaptor Example ¨ ¨ C++: std: : stack (or fsu: : CStack) Uses vector

Adaptor Example ¨ ¨ C++: std: : stack (or fsu: : CStack) Uses vector (existing code) to define stack interface http: //www. cs. fsu. edu/~lacher/courses/COP 4530/lectures/adts/sl ide 19. html Note: “inheritance” is conceptual, but not necessarily realized by inheritance in the specific language! COP 3331 Object-Oriented Analysis and Design 7

Bridge [A. 3] (wikipedia) COP 3331 Object-Oriented Analysis and Design 8

Bridge [A. 3] (wikipedia) COP 3331 Object-Oriented Analysis and Design 8

Bridge Example (text fig. 8 -7) Arena League. Store Stub Store Implementor COP 3331

Bridge Example (text fig. 8 -7) Arena League. Store Stub Store Implementor COP 3331 imp League. Store. Implementor JDBC Store Implementor XML Store Implementor Object-Oriented Analysis and Design 9

Comparing Adaptor and Bridge ¨ Using Inheritance and Delegation w Adaptor: inherits interface then

Comparing Adaptor and Bridge ¨ Using Inheritance and Delegation w Adaptor: inherits interface then delegates implementation w Bridge: delegates abstract implementation then derives specific implementations w Can derive from either construct ¨ Adaptor w Assumes existing (“legacy”) code w Adapted code may be old and ugly or modern and useful w Either way, you are not intending to change the existing code ¨ Bridge w Assumes you have not yet implemented the interface w Facilitates different implementation choices COP 3331 Object-Oriented Analysis and Design 10

Strategy [A. 9] (Text fig 8 -10) Application (client) Network. Connection (context) open() close()

Strategy [A. 9] (Text fig 8 -10) Application (client) Network. Connection (context) open() close() send() receive() set. Network. Interface() Location. Manager (policy) Ethernet open() close() send() receive() COP 3331 Network. Interface (strategy) Wave. LAN open() close() send() receive() Object-Oriented Analysis and Design UMTS open() close() send() receive() 11

Strategy Example ¨ ¨ The Strategy class (Network. Interface) provides common interface to various

Strategy Example ¨ ¨ The Strategy class (Network. Interface) provides common interface to various concrete networks The Context class (Network. Connection) gives client access to connection methods Client is a mobile application Policy monitors current location and (re)configures network connections with appropriate network interfaces COP 3331 Object-Oriented Analysis and Design 12

Command [A. 4] (text fig. 8 -13) Match * play() replay() Move execute() «binds»

Command [A. 4] (text fig. 8 -13) Match * play() replay() Move execute() «binds» Tic. Tac. Toe. Move Game. Board execute() Chess. Move execute() COP 3331 Object-Oriented Analysis and Design 13

Composite [A. 5] * Component move() resize() Label Button Checkbox Composite move() resize() Window

Composite [A. 5] * Component move() resize() Label Button Checkbox Composite move() resize() Window Panel Applet COP 3331 Object-Oriented Analysis and Design 14

Figure 8 -14, Anatomy of a preference dialog. Aggregates, called Panels, are used for

Figure 8 -14, Anatomy of a preference dialog. Aggregates, called Panels, are used for grouping user interface objects that need to be resized and moved together. Top panel Main panel Button panel COP 3331 Object-Oriented Analysis and Design 15

Figure 8 -15, UML object diagram for the user interface objects of Figure 8

Figure 8 -15, UML object diagram for the user interface objects of Figure 8 -14. prefs: Window top: Panel main: Panel title: Label c 1: Checkbox buttons: Panel ok: Button c 2: Checkbox cancel: Button c 3: Checkbox c 4: Checkbox COP 3331 Object-Oriented Analysis and Design 16

Abstract Factory [A. 1] Theft. Application House. Factory create. Bulb() create. Blind() EIBFactory Luxmate.

Abstract Factory [A. 1] Theft. Application House. Factory create. Bulb() create. Blind() EIBFactory Luxmate. Factory create. Bulb() create. Blind() Light. Bulb EIBBulb COP 3331 Blind Luxmate. Bulb Object-Oriented Analysis and Design EIBBulb Luxmate. Bulb 17

Façade [A. 6] Encapsulate complex systems COP 3331 Object-Oriented Analysis and Design 18

Façade [A. 6] Encapsulate complex systems COP 3331 Object-Oriented Analysis and Design 18

Observer [A. 7] (fig 8 -22) observers Subject 1 subscribe(Subscriber) unsubscribe(Subscriber) notify() Observer update()

Observer [A. 7] (fig 8 -22) observers Subject 1 subscribe(Subscriber) unsubscribe(Subscriber) notify() Observer update() Game. Board state get. State() play. Move() COP 3331 * Match. View game. Board update() Object-Oriented Analysis and Design 19

Proxy [A. 8] ¨ Whenever direct access is undesirable (security, performance, flexibility) COP 3331

Proxy [A. 8] ¨ Whenever direct access is undesirable (security, performance, flexibility) COP 3331 Object-Oriented Analysis and Design 20