200 likes | 228 Views
Explore the crucial aspects of software architecture design, including system design goals, design patterns, interfaces, and reusability concepts to create robust and scalable systems. Learn about inheritance, delegation, and various design patterns like Bridge, Adapter, Strategy, Command, Composite, and more.
E N D
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)
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
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
Delegation • Preferred for code reuse • Extensible: facilitates change of implementation • Does not create a false supertype • Delegation and Inheritance work together in design patterns
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
Client ClientInterface LegacyClass Request() ExistingRequest() Adapter Request() Adaptor [A.2] adaptee
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/slide19.html • Note: “inheritance” is conceptual, but not necessarily realized by inheritance in the specific language!
Bridge [A.3] (wikipedia)
Arena LeagueStore LeagueStoreImplementor Stub Store XML Store JDBC Store Implementor Implementor Implementor Bridge Example (text fig. 8-7) imp
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
Application (client) NetworkConnection (context) NetworkInterface (strategy) open() send() close() receive() send() setNetworkInterface() receive() LocationManager (policy) Ethernet WaveLAN UMTS open() open() open() close() close() close() send() send() send() receive() receive() receive() Strategy [A.9] (Text fig 8-10)
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
Match play() replay() GameBoard Command [A.4] (text fig. 8-13) * Move execute() «binds» TicTacToeMove execute() ChessMove execute()
move() resize() Composite [A.5] * Component move() resize() Label Button Checkbox Composite Window Panel Applet
Top panel Main panel Button panel 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.
Figure 8-15, UML object diagram for the user interface objects of Figure 8-14. prefs:Window top:Panel main:Panel buttons:Panel title:Label c1:Checkbox ok:Button c2:Checkbox cancel:Button c3:Checkbox c4:Checkbox
TheftApplication HouseFactory createBulb() createBlind() EIBFactory LuxmateFactory createBulb() createBulb() createBlind() createBlind() LightBulb Blind EIBBulb LuxmateBulb EIBBulb LuxmateBulb Abstract Factory [A.1]
Façade [A.6] Encapsulate complex systems
Observer [A.7] (fig 8-22) observers Subject Observer * 1 subscribe(Subscriber) update() unsubscribe(Subscriber) notify() GameBoard MatchView state gameBoard getState() update() playMove()
Proxy [A.8] • Whenever direct access is undesirable (security, performance, flexibility)