Download presentation
1
Part VII: Design Continuous
Interfaces and Subsystems Use case Realization in Design Object Oriented Analysis & Design & UML (Unified Modeling Language)
2
Object Oriented Analysis & Design & UML (Unified Modeling Language)
Content Interface What is an Interface? Finding Interfaces Designing with Interfaces Advantages and disadvantages of interfaces Interfaces and Component-Based Development Subsystems? Subsystems and Interfaces Physical Architecture and Layering Pattern Use case Realization in Design Object Oriented Analysis & Design & UML (Unified Modeling Language)
3
Object Oriented Analysis & Design & UML (Unified Modeling Language)
Chapter Roadmap Object Oriented Analysis & Design & UML (Unified Modeling Language)
4
Introduction Designing a subsystem
is concerned with breaking a system up into subsystems (as independent as possible) Interactions between subsystems are mediated by interfaces.
5
Object Oriented Analysis & Design & UML (Unified Modeling Language)
What is an Interface? Specifies a named set of operations Used to Separate the specification of functionality form implementation of functionality The interface provide The plugs and sockets To connect from outside The interface defines A contract implemented by the classifier Classifier: packaged in a subsytem or component Designing to implementation: Designing by connecting specific classes together Interface is realized by any number of classes An interface cannot be instantiated Object Oriented Analysis & Design & UML (Unified Modeling Language)
6
Object Oriented Analysis & Design & UML (Unified Modeling Language)
Interface Content Interface contains operations Fully specified: The attributes and operations of an interface should be fully specified, with: Complete operation signature The semantics of the operation (text or pseudocode) Name and type of the attributes Any operation or attribute stereotypes, constraints, tagged values Optional: A sterotype Name, Parameters and their types Return type Set of constraints Tagged values The followings are not allowed in interfaces Operation implementations Relationships Object Oriented Analysis & Design & UML (Unified Modeling Language)
7
UML Interface Notation
The set of interfaces realized by a classifier is known as provided interfaces, Note that the two different notations for the realization relationship Object Oriented Analysis & Design & UML (Unified Modeling Language)
8
Interfaces The set of interfaces Note that the two different notations
needed by a classifier for its operations are called required interfaces Note that the two different notations for the dependency relationship, with the socket symbol in the right-hand side
9
Interfaces an example of an assembled system
10
Interfaces Interfaces in Java: the collection classes
11
Interface realization vs. inheritance
“realizes contract specified by” Inheritance: “is a” Both can generate polymorphism Figure shows an inheritance-based solution
12
Interface realization vs. inheritance
Adding non-borrowable items such as journal needs further modeling
13
Interface realization vs. inheritance
A more elegant solution is To add LibraryItem between
14
Interface realization vs. inheritance
Still better is to combine inheritance and interfaces, Advantages: every item in the Library is a LibraryItem; borrowability concept factored out; fewer classes; simpler inheritance hierrachy; fewer compositions/inheritances
15
Interfaces and Time of Realization
Java Implements collection classes By Java you can leave realization to implementation time! Adding new devices via interface is very easy Object Oriented Analysis & Design & UML (Unified Modeling Language)
16
Object Oriented Analysis & Design & UML (Unified Modeling Language)
Finding Interfaces Consider to implement using interfaces: Challenge each of association If association needs flexibility Challenge each message send Can the same message send to more than one type of classes Factor out operation groups Might be reusable elsewhere Repeating in more than one class Look the classes playing the same role Role may indicate a possible interface Look for future expansion Interface makes easy for expansion! Object Oriented Analysis & Design & UML (Unified Modeling Language)
17
Designing with Interfaces
Design common protocols realized by many classes or components Example: A complex system with different communication protocols: Use open() close() read() write() Classes having reflexive associations are candidates for interfaces Interfaces Provide the ability to plug things to the systems Extension is easy Object Oriented Analysis & Design & UML (Unified Modeling Language)
18
Interfaces and Component-Based Development
To construct software from plug-in parts: One interface => multiple implementation Each implementation will abide the same contract Replace the component easily Coupling between the classes is reduced! Object Oriented Analysis & Design & UML (Unified Modeling Language)
19
Advantages and disadvantages of interfaces
Designing with interfaces increases flexibility and extensibility a model can be neatly separated in cohesive subsystems using interfaces supports low coupling by reducing the number of dependencies between classes, subsystems and components Drawbacks of interfaces relate to added complexity and increased performance costs As a guideline, use interfaces for the more “fluid” parts of the system and dispense them for the more stable parts of the system
20
Interfaces and component-based development
Interfaces are key elements for component-based development (CBD) They allow addition of “plug-in” parts without changing the specification Both with components and subsystems, interfaces support low coupling and provide high architectural flexibility
21
Components A component is It acts as a black box
a modular part of the system encapsulates its contents manifestation is replaceable within its environment It acts as a black box external behavior is completely defined by its interfaces (provided and required); hence, it can be replaced by any other component that supports the same protocol
22
Components Components may depend on other components
To decouple components, always mediate the dependency with interfaces
23
Component Stereotypes
24
Subsystems A subsystem is a component Interfaces connect subsystems
acts as unit of decomposition for a larger system Interfaces connect subsystems to create a system architecture Subsystems are used to: Separate design concerns Represent large-grained components Wrap legacy systems
25
Architecture and the layering pattern
Arrange subsytems and interfaces into layers that are semantically cohesive Connect subsystems via interfaces Java packages are just connected with dependencies!
26
Use case Realization in Design
27
Analysis Interaction Diagram
Add Course at Analysis
28
Design Level Diagram added the GUI layer,
high-level operations are resolved into specific methods of classes, complete with parameters object construction is shown by an explicit constructor method invocation.
29
Subsystem interactions
Once physical architecture of subsystems and interfaces are designed model use case realizations as interactions between subsystems rather than as interactions between classes. Interactions between subsystems provide a very useful high-level view of how the architecture realizes use cases without going into the low-level details of individual object interactions.
30
Customer Subsystem with a single interface: CustomerManager
actor interacting with this subsystem. As the subsystem provides realizations for all of its interfaces and operations we show the messages on the interaction diagram going to the subsystem itself
31
Object Oriented Analysis & Design & UML (Unified Modeling Language)
End of Chapter Object Oriented Analysis & Design & UML (Unified Modeling Language)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.