Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 19: Interfaces and Components

Similar presentations


Presentation on theme: "Chapter 19: Interfaces and Components"— Presentation transcript:

1 Chapter 19: Interfaces and Components
CS 426 Senior Projects in Computer Science Chapter 19: Interfaces and Components [Arlow and Neustadt, 2005] University of Nevada, Reno Department of Computer Science & Engineering

2 Interfaces and Components
Outline Interfaces and subsystems: Introduction Interfaces Interface realization vs. inheritance Components Subsystems Finding interfaces The layering pattern Advantages and disadvantages of interfaces Interfaces and Components

3 1 Introduction Chapter 19 roadmap, Fig [Arlow & Neustadt, 2005]

4 1 Introduction Designing large software applications is concerned with breaking a system up into subsystems (as independent as possible) Interactions between subsystems are mediated by interfaces

5 Interfaces and Components
An interface specifies a named set of public features It defines a contract (set of services) to be implemented by a classifier It also separates specification from implementation An interface cannot be instantiated Anything that realizes an interface (e.g., a class) must accept and agree by the contract defined by the interface Interfaces and Components

6 Interfaces and Components
Interface features that need to be realized Interfaces and Components

7 Interfaces and Components
Interfaces allow “design to a contract” as compared to “design to an implementation” supported by classes This provides a high degree of flexibility Modern software architectures are based on the concept of service, supported by interfaces 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 Interfaces and Components

8 Interfaces and Components
The set of interfaces realized by a classifier is known as provided interfaces, with UML syntax (two styles) shown in Fig [Arlow & Neustadt 2005] Note that the two different notations for the realization relationship Interfaces and Components

9 Interfaces and Components
The set of interfaces needed by a classifier for its operations are called required interfaces, as shown in Fig [Arlow & Neustadt 2005] Note that the two different notations for the dependency relationship, with the socket symbol in the right-hand side Interfaces and Components

10 Interfaces and Components
Example of an assembled system Interfaces and Components

11 Interfaces and Components
Interfaces in Java: the collection classes Interfaces and Components

12 3 Interface realization vs. inheritance
Interface: “realizes contract specified by” Inheritance: “is a” Both can generate polymorphism Example of inheritance-based solution shown here Interfaces and Components

13 3 Interface realization vs. inheritance
Adding non-borrowable items such as journal needs further modeling Interfaces and Components

14 3 Interface realization vs. inheritance
A more elegant solution is shown below Interfaces and Components

15 3 Interface realization vs. inheritance
Still better is to combine inheritance and interfaces, as below . Advantages: every item in the Library is a LibraryItem; borrowability concept is factored out; fewer classes; simpler inheritance hierarchy; fewer compositions and inheritances Interfaces and Components

16 4 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 Interfaces and Components

17 Interfaces and Components
A component is a “modular part of the system that encapsulates its contents and whose manifestation is replaceable within its environment” It acts as a black box whose external behaviour is completely defined by its interfaces (provided and required) UML notation: Interfaces and Components

18 Interfaces and Components
Components may depend on other components To decouple components, mediate the dependency with interfaces Interfaces and Components

19 4 Components Component stereotypes

20 Interfaces and Components
5 Subsystems A subsystem is a component that 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 A system example is shown here Interfaces and Components

21 Interfaces and Components
6 Finding Interfaces Techniques for finding interfaces in a system or subsystem: Challenge each association and each message Factor out groups of operations reusable elsewhere Factor out groups of operations that repeat in classes Factor out sets of attributes that repeat in classes Look at classes that have similar roles in the system Consider future extensions Interfaces and Components

22 7 Architecture and the layering pattern

23 7 Architecture and the layering pattern: HEDC

24 8 Advantages and disadvantages of interfaces
Designing with interfaces increases flexibility and extensibility Also, using interfaces supports low coupling With interfaces, a model can be neatly separated in cohesive subsystems 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 of them for the more stable parts Interfaces and Components


Download ppt "Chapter 19: Interfaces and Components"

Similar presentations


Ads by Google