The previous articles covered two of the three primary areas in which the UML diagrams are categorized (see Article 1)—Static and Dynamic. The remaining two UML diagrams that fall under the category of Implementation are the Component and Deployment diagrams. In this article, we will discuss the Component diagram.
The different high-level reusable parts of a system are represented in a Component diagram. A component is one such constituent part of a system. In addition to representing the high-level parts, the Component diagram also captures the inter-relationships between these parts.
So, how are component diagrams different from the previous UML diagrams that we have seen? The primary difference is that Component diagrams represent the implementation perspective of a system. Hence, components in a Component diagram reflect grouping of the different design elements of a system, for example, classes of the system.
Let us briefly understand what criteria to apply to model a component. First and foremost, a component should be substitutable as is. Secondly, a component must provide an interface to enable other components to interact and use the services provided by the component. So, why would not a design element like an interface suffice? An interface provides only the service but not the implementation. Implementation is normally provided by a class that implements the interface. In complex systems, the physical implementation of a defined service is provided by a group of classes rather than a single class. A component is an easy way to represent the grouping together of such implementation classes.
You can model different types of components based on their use and applicability in a system. Components that you can model in a system can be simple executable components or library components that represent system and application libraries used in a system. You also can have file components that represent the source code files of an application or document files that represent, for example, the user interface files such as HTML or JSP files. Finally, you can use components to represent even the database tables of a system as well!
Now that we understand the concepts of a component in a Component diagram, let us see what notations to use to draw a Component diagram.
Elements of a Component Diagram
A Component diagram consists of the following elements:
|Element and its description||Symbol|
|Component: The objects interacting with each other in the system. Depicted by a rectangle with the name of the object in it, preceded by a colon and underlined.|
|Class/Interface/Object: Similar to the notations used in class and object diagrams|
|Relation/Association: Similar to the relation/association used in class diagrams|
Creating a Component Diagram
Figure 1 Screen shot of the Poseidon tool
The screen shot of the Poseidon tool in Figure 1 shows the different options to model components in a Component diagram and define interactions between these components.
Case Study—Courseware Management System
From our above discussion of the Component diagram, we will apply the criteria for identifying components to the Courseware Management System. In the first instance, the application may seem to be too simplistic to contain components. But wait! The Courseware Management System has its own share of components, some implicit in the design.
Before we move to identifying the components, let us recap a quick discussion that we had regarding the Model View Controller architecture in the UML Class Diagram Part II article. In this article we had mentioned that the different classes in the class diagram can be partitioned along the lines of the three layers of this architecture viz. Model, View, and Controller. This partitioning of the different classes of the application poses its own challenges, the primary one being how do the classes in one layer interact with the classes in the other layers. Let us elaborate this by reviewing the classes in the Courseware Management System.
Identifying Components in the Courseware Management System
The different classes that we have modeled for the Courseware Management System, such as CourseAdministrator, Course, Topic, CourseCalendar, and Student that fall in the Model layer need to provide a consistent interface to enable other classes and components to interact with them and utilize their services. We can as well define our own set of simple interface methods to access these services. But, to enable our application components to be used by external applications, we can consider basing the components on well-defined component standards.
Hence, based on the technology that you use, you would model these as, maybe Enterprise JavaBeans (EJBs) or Component Object Model/Distributed Component Object Model (COM/DCOM) components. EJB and COM/DCOM are nothing but industry-standard component models that you can base your application component design on. This becomes the “physical” implementation of the logical class diagram. An added advantage of basing your application components on these component models is that your components become “reusable!”
So, if we had introduced a controller class for the application named CMSController, it would interact with the components in the Model layer via the EJB or the COM/DCOM interfaces.
Based on this, let us now draw the components in the Model layer for the Courseware Management System.
Figure 2 Component diagram for the Courseware Management System
Figure 2 shows the Component diagram for the Model layer of the Courseware Management System. The diagram shows the different components, such as CourseAdministrator, Course, Topic, Tutor, and so forth in the Model layer and how the Controller layer component interacts with these components. The diagram also depicts a database access component that represents a library component that the Model layer components will use to interact with a database.
In this article, we briefly discussed Component diagrams. In the next article, we will cover the last UML diagram—the Deployment diagram.
About the Authors
Mandar S. Chitnis, Lakshmi Ananthamurthy, and Pravin S. Tiwari are the co-founders of Novusware, Inc. They have co-authored the book Teach Yourself BEA WebLogic Server 7.0 in 21 Days (SAMS Publishing, October 2002) based on the recently launched WebLogic Server 7.0 by BEA Systems, Inc.
For any questions or queries regarding the article contents, please contact firstname.lastname@example.org.