1.COMPONENT

2. PACKAGE DIAGRAMS What is a ?

– A component is an autonomous unit within a system – UML component diagrams enable to model the high-level software components, and the interfaces to those components – Important for component-based development (CBD) – Component and subsystems can be flexibly REUSED and REPLACED – UML components diagrams are Implementation diagrams i.e., it describe 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 you are 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 <> – 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 – 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 dependencies A usage is relationship which one element requires another element for its full implementation – Ports Port 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 of provided 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 <> 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 <> 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

All interactions of a component with its environment are achieved through a 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 SearchVideo interfaces and requires Inventory interface. 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 the Delegation connector from the delegating port to the simple port of simple port of Authentication SearchEngine component 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 of Assembly connector between simple ports of Authentication and Customers components Authentication and Customers components External and Internal View of Component EXTERNAL VIEW

 A component have an external view and an internal 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 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 shopping ex(for reference) Diagram explanation

– The diagram shows "white-box" view of the internal structure of three related subsystems - WebStore, Warehouses, and Accounting. – WebStore subsystem contains three components related to online shopping - Search Engine, Shopping Cart, and Authentication. Search Engine component allows to search or browse items by exposing provided interface Product Search and uses required interface Search Inventory provided by Inventory component. Shopping Cart component uses Manage Orders interface provided by Orders component during checkout. Authentication component allows customers to create account, login, or logout and binds customer to some account. – Accounting subsystem provides two interfaces - Manage Orders and Manage Customers. Delegation connectors link these external contracts of the subsystem to the realization of the contracts by Orders and Customers components. – Warehouses subsystem provides two interfaces Search Inventory and Manage Inventory used by other subsystems and wired through dependencies. What is a ?

– 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 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.hibernate contains Package org.hibernate SessionFactory 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 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 one another. • To divide a complex system into module • Package diagrams can use packages that represent the different layers of a software system to illustrate the layered architecture of a software system. THANK YOU