Saturday, August 22, 2009

UML 2.0 Component Diagrams – Modeling the System Logical Architecture

In UML 2.0 Component diagrams are used to model the logical architecture of a system by showing the system high level components and their inter-relationships. In the next post I will show how components are used in deployment diagrams to model the physical architecture of a system. 

A component is an encapsulated unit within a system which provide one or more interfaces. When using components to model the logical architecture (solely in component diagrams) of a system the term ‘component’ refers to collection of classes which can be reused and replaced as a whole, when a single logical component can scattered around multiple physical nodes. When using components to model the physical architecture of a system (usually in deployment diagrams, but some people that are still custom to UML 1.x still use it in component diagrams) the term ‘component’ refers to dll, or some executable.

Simple Wiring

Abstract Connector

The most simple and abstract way to illustrated relationships between components is by using the dependency connector which can refer to wide range of dependent relationships like realization and usage

image

By wiring two components with the dependency connector we state that some of the classes/interfaces in component2 are being required/realized/implemented by classes/interfaces from component1.

Generalization Connector

To show that some classes in component1 derive from classes in component2 we use the ‘generalization’ connector.

 image

Overall Look

Lets see how component diagram with simple wiring can be used to model a simple orders management application which includes UI editors, repository, and web service.

Notice that stereotypes are being be used to divide the components to layers in order to distinguish between application components (views, controllers, presenters), domain components (business logic, data access layer) and infrastructure components.

image

The ‘Orders Management’ and ‘Admin’ components include application level classes such as UI editors and presentation logic classes, which derive from framework level classes that reside within ‘System.Windows.Forms’ (Control, Component, UserControl, Form etc). The ‘Orders’ component includes domain level classes such as repository which uses web-service classes from ‘WebServices.Orders’ component . Classes from both ‘Admin’ and ‘Orders’ components use the infrastructure level ‘Login’ component in order or login to the system.

Interfaces Wiring

In order to be more specific regarding to the relationships between the components - we show the interfaces that the components expose and require, and the way in which they are wired together.

Socket Connector

The socket connector which is new to UML 2.0 shows that a component requires a specific interface. The figure bellow shows that the component ‘Orders Management’ requires ‘Orders Repository’ interface.

image

Lollipop Connector

The lollipop connector shows that a component exposes a specific interface.

image

Wiring the Connectors - Realization

The connectors can be wired together to show that one (or more) of the classes/interfaces of a component realizes an interface exposed by other component. In this case the ‘Orders’ component contains a class that realizes the ‘IOrdersWebService’ interface exposed  by the ‘WebServices.Orders’ component.

image 

Wiring the Connectors – Usage

In other cases the connectors can be wired together to show that one component requires an interface which the other component exposes. In this case the ‘Orders Management’ component requires the ‘Order Repository’ interface of the ‘Orders’ component.

image 

UML 2.0 introduces the assembly connector that shows the exact same thing.

image

Overall Look

The following figure shows how the same architecture from the ‘simple wiring’ section can be modeled in more details by pointing out the interfaces that the components expose and require.

image

Now we can see that the ‘Orders’ component realizes the ‘IOrdersWebService’ interface and uses some of the classes of ‘WebServices.Orders’ component.

The ‘Orders’ and the ‘WebServices.Orders’ components execute on different nodes. The ‘Orders’ component (client) contains a proxy class which realizes the ‘IOrdersWebService’ interface. The ‘WebServices.Orders’ component (server) contains a web service class which also implements the ‘IOrdersWebService’ interface. The proxy initiate remote calls on the web service object through the ‘IOrdersWebService’ interface.

The ‘Login’ component exposes the ‘ILoginManager’ interface through which the ‘Orders Management’ and the ‘Admin’ components login to the system.

Both ‘Login’ and ‘Admin’ components contain proxy object that initiate remote calls on the the web service object that resides within ‘WebServices.Users’ through the ‘IUsersWebService’ interface.

Links

http://www.ibm.com/developerworks/rational/library/dec04/bell/

No comments:

Post a Comment