Docsity

Interfaces and Components-Object-Oriented Design-Lecture 18 Slides-Computer Engineering, Slides of Object Oriented Analysis and Design

Partial preview of the text

Download Interfaces and Components-Object-Oriented Design-Lecture 18 Slides-Computer Engineering and more Slides Object Oriented Analysis and Design in PDF only on Docsity!

Department of Computer Engineering

Sharif University of Technology

Object-Oriented Design

Lecturer: Raman Ramsin

Lecture 18 :

Interfaces and Components

Department of Computer Engineering

Sharif University of Technology

Design Workflow: Architecture and Subsystems  Place in the Design Workflow:  Architectural Design  Design a Use Case  Design a Class  Design a Subsystem  concerned with breaking a system up into subsystems that are as independent as possible.  Interactions between subsystems are mediated by interfaces.

Department of Computer Engineering

Sharif University of Technology

Interface Semantics  A classifier realizing an interface has the following responsibilities for each feature:

Department of Computer Engineering

Sharif University of Technology

Alternative Design Approaches  Designing to an implementation :  specific classes are connected;  to keep things simple (but rigid), design to an implementation.  Designing to a contract :  a class is connected to an interface that may have many possible realizations;  to make things flexible (but possibly more complex), design to a contract.

Department of Computer Engineering

Sharif University of Technology

Required Interface  An interface required by a classifier:  the classifier requires another classifier that realizes the interface;  show a dependency to a class style interface, a lollipop style interface, or use an assembly connector.

Department of Computer Engineering

Sharif University of Technology

Assembly Connector  Joins provided and required interfaces.

Department of Computer Engineering

Sharif University of Technology

Interface Realization vs. Inheritance  Interface realization - "realizes a contract specified by".  Inheritance - "is a".  Both inheritance and interface realization generate polymorphism.  Use interfaces to specify the common protocols of classes that should not normally be related by inheritance.

Department of Computer Engineering

Sharif University of Technology

Interface Realization vs. Inheritance: Example

Department of Computer Engineering

Sharif University of Technology

Components  Component - a modular part of a system that encapsulates its contents and whose manifestation is replaceable within its environment:  may have attributes and operations;  may participate in relationships;  may have internal structure;  its external behavior is completely defined by its provided and required interfaces;  components manifest one or more artifacts.

Department of Computer Engineering

Sharif University of Technology

Components: Standard Stereotypes

Department of Computer Engineering

Sharif University of Technology

Subsystems: Applications  Subsystems are used to:  separate design concerns;  represent large-grained components;  wrap legacy systems.

Department of Computer Engineering

Sharif University of Technology

Designing with Interfaces  Use interfaces to hide the implementation details of subsystems:  the Facade pattern hides a complex implementation behind a simple interface;  the layering pattern organizes subsystems into semantically cohesive layers:  dependencies between layers should only go one way;  all dependencies between layers should be mediated by an interface;  example layers include presentation, business logic, and utility layers.

Department of Computer Engineering

Sharif University of Technology

Finding Interfaces: Guidelines  challenge associations;  challenge message sends;  factor out groups of reusable operations;  factor out groups of repeating operations;  factor out groups of repeating attributes;  look for classes that play the same role in the system;  look for possibilities for future expansion;  look for dependencies between components.

Department of Computer Engineering

Sharif University of Technology

Reference  Arlow, J., Neustadt, I., UML 2 and the Unified Process: Practical Object-Oriented Analysis and Design, 2

nd

Ed. Addison-Wesley,