1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to...

41
1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS

Transcript of 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to...

Page 1: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

1.COMPONENT

DIAGRAMS

2. PACKAGE

DIAGRAMS

Page 2: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

What is a component?

– A component is an autonomous unit within a system

– UML component diagrams enable to model the high-levelsoftware components, and the interfaces to thosecomponents

– Important for component-based development (CBD)

– Component and subsystems can be flexibly REUSED andREPLACED

– UML components diagrams are Implementation diagrams i.e., itdescribe the different elements required for implementing a system

Page 3: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

Example

– When you build a house, you must do more than create blueprints

– you've got to turn your floor plans and elevation drawings into real walls, floors, and ceilings made of wood, stone, or metal.

– If youare renovating a house, you'll reuse even larger components, such as whole rooms and frameworks.

– Same is the case when we develop software….

Page 4: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect
Page 5: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

COMPONENT NOTATION

– A component is shown as a rectangle with

– A keyword <<component>>

– Optionally, in the right hand corner a component icon can be displayed

– A component icon is a rectangle with two smaller rectangles jutting out from the left-hand side

– This symbol is a visual stereotype

– The component name

Page 6: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

Component types

Components in UML could represent

– logical components (e.g., business components, process

components)

– physical components (e.g., EJB components, COM+ and .NET

components)

Page 7: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

Component ELEMENTS

– A component can have– Interfaces

An interface represents a declaration of a set of operations

– Usage dependenciesA usage dependency is relationship which one element requires another

element for its full implementation

– PortsPort represents an interaction point between a component and its

environment

– Connectors – Connect two components

– Connect the external contract of a component to the internal structure

Page 8: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

INTERFACE

– A component defines its behaviour in terms ofprovided and required interfaces

– An interface

– Is the definition of a collection of one or more operations

– Provides only the operations but not the implementation

– Implementation is normally provided by a class/ component

Page 9: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

INTERFACE

– May be shown using a rectangle symbol with a keyword <<interface>> preceding the name

Can be

Provided

Required

Page 10: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

Provided Interface

– A provided interface

– Characterize services that the component offers to its environment

– Is modeled using a ball, labelled with the name, attached by a solid line to the component

Weather Services component provides (implements)Weather Forecast interface

Page 11: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

Required Interface

– A required interface

– Characterize services that the component expects from its environment

– Is modeled using a socket, labelled with the name, attached by a solid line to the component

User Services component requires IOrderServices interface

Page 12: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

INTERFACE

– Where two components/classes provide and require the same interface, these two notations may be combined

The ball-and-socket notation hint at that interface in question serves to mediate interactions between the two components

Page 13: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

DEPENDENCIES

– Components can be connected by usage dependencies

– Usage Dependency – A usage dependency is relationship which one element

requires another element for its full implementation

– Is shown as dashed arrow with a <<use>> keyword

– The arrowhead point from the dependent component to the one of which it is dependent

Page 14: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

PORT

– Specifies a distinct interaction point

– Between that component and its environment

– Between that component and its internal parts

– Is shown as a small square symbol– Ports can be named, and the name is placed near the square

symbol– Is associated with the interfaces

Library Services class has port searchPort.

Page 15: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

PORT

Ports can support unidirectional communication or bi-directional communication

Page 16: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

PORT

– A provided interface may be shown using the "lollipop" notation attached to

the port. A required interface may be shown using the "socket" notation

attached to the port.

Port searchPort provides SearchBooks and SearchVideointerfaces and requires Inventory interface.

All interactions of a component with its environment are achieved through a port

Page 17: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

Connectors

– Connector is feature which specifies a link that enables communication

between two or more instances playing some roles.

– Connector linking components could be either:

delegation connector.

assembly connector.

Page 18: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

Delegation Connector

– A delegation connector Links the external contract of a component to the internal realization

– Represents the forwarding of signals

– A delegation connector is notated as a connector from the delegating port to

the handling port or part.

Delegation connector from the delegating port to the UserServlet part

Page 19: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

Delegation connector examples

Delegation connector from thedelegating port to the simple port ofSearchEngine

Delegation connector from thesimple port of Authenticationcomponent to the delegating port.

Page 20: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

Assembly Connector

– An assembly connector is a connector between 2 components defines that one component provides the services that another component requires

Assembly connector between ports ofAuthentication and Customers components

Assembly connector between simple ports ofAuthentication and Customers components

Page 21: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

External and Internal View of

Component

Page 22: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

EXTERNAL VIEW

– An external view (or black box view) shows publicly visible properties and operations

An external view of a component is by means of interface symbols sticking out of the component box

The interface can be listed in the compartment of a component box

A component have an external view and an internal view

Page 23: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

INTERNAL VIEW

– An internal, or white box view of a component is where the realizing classes/components are nested within the component shape

Realization is a relationship between two set of model elements One represents a specification The other represent an implementation of the

latter

Page 24: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

Component diagram shopping ex(for reference)

Page 25: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

Diagram explanation

– The diagram shows "white-box" view of the internal structure of three relatedsubsystems - WebStore, Warehouses, and Accounting.

– WebStore subsystem contains three components related to online shopping -Search Engine, Shopping Cart, and Authentication. Search Engine componentallows to search or browse items by exposing provided interface Product Search anduses required interface Search Inventory provided by Inventory component.Shopping Cart component uses Manage Orders interface provided by Orderscomponent during checkout. Authentication component allows customers to createaccount, login, or logout and binds customer to some account.

– Accounting subsystem provides two interfaces - Manage Orders and ManageCustomers. Delegation connectors link these external contracts of the subsystem tothe realization of the contracts by Orders and Customers components.

– Warehouses subsystem provides two interfaces Search Inventory and ManageInventory used by other subsystems and wired through dependencies.

Page 26: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

What is a Package Diagram?

– Package is a namespace used to group together elements that are semantically

related and might change together.

– Package diagram is UML structure diagram which shows structure of the

designed system at the level of packages.

– The following elements are typically drawn in a package diagram:

– package, packageable element, dependency, element import, package import,

package merge.

Page 27: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

Package elements

– Owned Element ( or packageable element)

– Owned members of a package should all be packageable elements. If a package is

removed from a model, so are all the elements owned by the package.

– Imported Element

Page 28: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

Package notation

– A package is rendered as a tabbed folder - a rectangle with a small tab attached

to the left side of the top of the rectangle.

Package org.hibernatePackage org.hibernate containsSessionFactory and Session

Page 29: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

Members of the package shown

outside of the package

Page 30: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

Nested packages

Graphics class is Java::Utilities::Graphics

Page 31: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

Package Visibility

– Visibility of Owned and Import element.

– "+" for public and "-" for private or helper class.

– All elements of Library Domain package are public except for Account.

Page 32: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

Package Relationships

Page 33: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

Element Import and access

– An element import is shown using a dashed arrow with an open arrowhead

from the importing namespace to the imported element.

– The keyword «import» is shown near the dashed arrow if the visibility is public

– The keyword «access» is shown to indicate private visibility

– Public import of PageInfo element and private import of SortInfo element from

Domain package.

Page 34: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

Package Import

– A package import is shown using a dashed arrow with an open arrowhead from

the importing namespace to the imported package.

Page 35: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

Package Merge

– A package merge is a directed relationship between two packages.

– It indicates that content of one package is extended by the contents of another

package.

– Package merge used when elements defined in different packages have the

same name and are intended to represent the same concept.

– Package merge is shown using a dashed line with an open arrowhead pointing

from the receiving package to the merged package.

Page 36: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect
Page 37: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

Dependency

Page 38: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

Examples

Use case package Diagram

Page 39: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

Class package diagram

Page 40: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

Use of package diagram

• When you want to show high level view of the system.

• To keep track of dependencies.

• With the large system to show its major element and how they relate to oneanother.

• To divide a complex system into module

• Package diagrams can use packages that represent the different layers of asoftware system to illustrate the layered architecture of a software system.

Page 41: 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to model the high-level software components, and the interfaces to those components ... – Connect

THANK YOU