1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to...
-
Upload
phungquynh -
Category
Documents
-
view
231 -
download
0
Transcript of 1.COMPONENT DIAGRAMS 2. PACKAGE DIAGRAMS · PDF file–UML component diagrams enable to...
1.COMPONENT
DIAGRAMS
2. PACKAGE
DIAGRAMS
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
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….
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
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)
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
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
INTERFACE
– May be shown using a rectangle symbol with a keyword <<interface>> preceding the name
Can be
Provided
Required
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
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
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
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
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.
PORT
Ports can support unidirectional communication or bi-directional communication
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
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.
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
Delegation connector examples
Delegation connector from thedelegating port to the simple port ofSearchEngine
Delegation connector from thesimple port of Authenticationcomponent to the delegating port.
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
External and Internal View of
Component
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
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
Component diagram shopping ex(for reference)
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.
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.
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
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
Members of the package shown
outside of the package
Nested packages
Graphics class is Java::Utilities::Graphics
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.
Package Relationships
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.
Package Import
– A package import is shown using a dashed arrow with an open arrowhead from
the importing namespace to the imported package.
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.
Dependency
Examples
Use case package Diagram
Class package diagram
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.
THANK YOU