Download presentation
Presentation is loading. Please wait.
Published byFrederick West Modified over 8 years ago
1
COP 3331 Object-Oriented Analysis and Design 1 Design Overview Design Overview (Ch 6) Review of RAD System Design System Design Concepts System Design Goals (Global) System Design (Ch 7) Design Goals Software Architecture Boundary Use Cases SDD Subsystem Design Patterns (Ch 8) Interfaces (Ch 9) Mapping to Code (Ch 10)
2
COP 3331 Object-Oriented Analysis and Design 2 Re-Use Design Patterns Adapter, Bridge Strategy, Command, Composite Abstract Factory Frameworks Infrastructure Middleware Application Whitebox / Blackbox Libraries Domain neutral Independent and fine grain Control passive Components Predefined instances (pre-compiled code) Not modifiable
3
COP 3331 Object-Oriented Analysis and Design 3 Inheritance Specification inheritance (recommended) Interface inheritance Re-use interface Create a subtype Example (from 3330): vehicle / truck / tanker Implementation inheritance (use with caution) Re-use (implementation) code Example: List / OrderedList Problems: Not extensible (hard to change the implementation) Not a subtype: can’t substitute for base class C++ private inheritance overcomes subtype issue Liskov Substitution Principle (LSP) Definition: S is a subtype of T iff an object of type S can be substituted whenever an object of type T is expected Principle: Use inheritance only for subtyping
4
COP 3331 Object-Oriented Analysis and Design 4 Delegation Preferred for code reuse Extensible: facilitates change of implementation Does not create a false supertype Delegation and Inheritance work together in design patterns
5
COP 3331 Object-Oriented Analysis and Design 5 Design Patterns Name Uniquely identifies pattern Evokes details to designer Problem description Describes situations appropriate for using the pattern Usually includes modifiability, extensibility, and nonfunctional design goals Solution State as a set of collaborating entities (mostly classes and objects) Typically includes an illustration Consequences Describe the trade-offs and alternatives with respect to the design goals being addressed
6
COP 3331 Object-Oriented Analysis and Design 6 Adaptor [A.2] ClientInterface Request() adaptee LegacyClass ExistingRequest() Adapter Request() Client
7
COP 3331 Object-Oriented Analysis and Design 7 Adaptor Example C++: std::stack (or fsu::CStack) Uses vector (existing code) to define stack interface http://www.cs.fsu.edu/~lacher/courses/COP4530/lectures/adts/sl ide19.html http://www.cs.fsu.edu/~lacher/courses/COP4530/lectures/adts/sl ide19.html Note: “inheritance” is conceptual, but not necessarily realized by inheritance in the specific language!
8
COP 3331 Object-Oriented Analysis and Design 8 Bridge [A.3] (wikipedia)
9
COP 3331 Object-Oriented Analysis and Design 9 Bridge Example (text fig. 8-7) LeagueStoreImplementorLeagueStore imp XML Store Implementor Stub Store Implementor JDBC Store Implementor Arena
10
COP 3331 Object-Oriented Analysis and Design 10 Comparing Adaptor and Bridge Using Inheritance and Delegation Adaptor: inherits interface then delegates implementation Bridge: delegates abstract implementation then derives specific implementations Can derive from either construct Adaptor Assumes existing (“legacy”) code Adapted code may be old and ugly or modern and useful Either way, you are not intending to change the existing code Bridge Assumes you have not yet implemented the interface Facilitates different implementation choices
11
COP 3331 Object-Oriented Analysis and Design 11 Strategy [A.9] (Text fig 8-10) NetworkInterface (strategy) open() close() send() receive() NetworkConnection (context) send() receive() setNetworkInterface() LocationManager (policy) Application (client) Ethernet open() close() send() receive() WaveLAN open() close() send() receive() UMTS open() close() send() receive()
12
COP 3331 Object-Oriented Analysis and Design 12 Strategy Example The Strategy class (NetworkInterface) provides common interface to various concrete networks The Context class (NetworkConnection) gives client access to connection methods Client is a mobile application Policy monitors current location and (re)configures network connections with appropriate network interfaces
13
COP 3331 Object-Oriented Analysis and Design 13 Command [A.4] (text fig. 8-13) GameBoard «binds» TicTacToeMove execute() ChessMove execute() Move execute() Match * replay() play()
14
COP 3331 Object-Oriented Analysis and Design 14 Composite [A.5] Component * CheckboxButtonCompositeLabel Panel Window Applet move() resize() move() resize()
15
COP 3331 Object-Oriented Analysis and Design 15 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
16
COP 3331 Object-Oriented Analysis and Design 16 Figure 8-15, UML object diagram for the user interface objects of Figure 8-14. top:Panel prefs:Window ok:Button main:Panelbuttons:Panel title:Label c2:Checkbox c3:Checkbox c4:Checkbox cancel:Button c1:Checkbox
17
COP 3331 Object-Oriented Analysis and Design 17 Abstract Factory [A.1] HouseFactory LightBulb EIBBulbLuxmateBulb LuxmateFactory EIBFactory createBulb() createBlind() Blind EIBBulbLuxmateBulb TheftApplication createBulb() createBlind() createBulb() createBlind()
18
COP 3331 Object-Oriented Analysis and Design 18 Façade [A.6] Encapsulate complex systems
19
COP 3331 Object-Oriented Analysis and Design 19 Observer [A.7] (fig 8-22) GameBoard state getState() playMove() Observer update() MatchView gameBoard update() observers * 1 Subject subscribe(Subscriber) unsubscribe(Subscriber) notify()
20
COP 3331 Object-Oriented Analysis and Design 20 Proxy [A.8] Whenever direct access is undesirable (security, performance, flexibility)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.