Part VII: Design Continuous Interfaces and Subsystems Use case Realization in Design 24.04.2017 Object Oriented Analysis & Design & UML (Unified Modeling Language)
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 24.04.2017 Object Oriented Analysis & Design & UML (Unified Modeling Language)
Object Oriented Analysis & Design & UML (Unified Modeling Language) Chapter Roadmap 24.04.2017 Object Oriented Analysis & Design & UML (Unified Modeling Language)
Introduction Designing a subsystem is concerned with breaking a system up into subsystems (as independent as possible) Interactions between subsystems are mediated by interfaces.
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 24.04.2017 Object Oriented Analysis & Design & UML (Unified Modeling Language)
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 24.04.2017 Object Oriented Analysis & Design & UML (Unified Modeling Language)
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 24.04.2017 Object Oriented Analysis & Design & UML (Unified Modeling Language)
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
Interfaces an example of an assembled system
Interfaces Interfaces in Java: the collection classes
Interface realization vs. inheritance “realizes contract specified by” Inheritance: “is a” Both can generate polymorphism Figure shows an inheritance-based solution
Interface realization vs. inheritance Adding non-borrowable items such as journal needs further modeling
Interface realization vs. inheritance A more elegant solution is To add LibraryItem between
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
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 24.04.2017 Object Oriented Analysis & Design & UML (Unified Modeling Language)
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! 24.04.2017 Object Oriented Analysis & Design & UML (Unified Modeling Language)
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 24.04.2017 Object Oriented Analysis & Design & UML (Unified Modeling Language)
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! 24.04.2017 Object Oriented Analysis & Design & UML (Unified Modeling Language)
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
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
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
Components Components may depend on other components To decouple components, always mediate the dependency with interfaces
Component Stereotypes
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
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!
Use case Realization in Design
Analysis Interaction Diagram Add Course at Analysis
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.
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.
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
Object Oriented Analysis & Design & UML (Unified Modeling Language) End of Chapter 24.04.2017 Object Oriented Analysis & Design & UML (Unified Modeling Language)