Sei sulla pagina 1di 36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

Chapter 6
More About Static Modeling
Static modeling uses class diagrams and object diagrams to represent the static constituents of a software system. These diagrams use various types of notations for depicting different types of classes and the relationships between them. In addition, these diagrams use special types of constructs called interfaces. This chapter discusses the various types of classes and examines the relationships between them. It also explains the concept of interfaces and the different UML notations used to depict interfaces.

Objectives
In this chapter, you will learn to: Identify various types of classes and the relationships between them Identify Interfaces

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

1/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

Identifying Types of Classes and Relationships Between Classes


After you identify the classes from the problem statement or use cases, you can classify the identified classes into various types. This enables you to make the software system reusable and manageable.

Types of Classes
UML enables you to classify classes into the following types: Abstract class Parameterized class Factory class Self-linked class

Abstract Class
An abstract class is a class that does not have any direct instances. However, the classes inherited from an abstract class can have direct instances. An abstract class is used to define the common features and common behavior of a set of subclasses. Consider the example of an A u t o m o b i l eclass. Some of the attributes of the A u t o m o b i l eclass are: Has wheels Has an engine Has a color You can derive two subclasses B u sand C a rfrom the A u t o m o b i l eclass. In this case, you may never be required to create an object of the A u t o m o b i l eclass in your program. Instead, you may want to use it only because you want it to act as a superclass that defines the common attributes for the C a rand B u s classes. In this case, you can declare the A u t o m o b i l eclass as an abstract class. The UML notation for an abstract class is same as that of a simple class. However, the name of the class is italicized to indicate that the class is an abstract class. The following figure depicts the UML notation for an abstract class.

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

2/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

Parameterized Class
A parameterized class, also called template class, provides a mechanism that enables you to use operations and classes to work with different data types. A parameterized class consists of type parameters that are unbounded, which means that the data types of the parameters are not defined in the parameterized class. You cannot create the objects of a parameterized class. To use the functions defined in the parameterized class, you need to realize the parameterized class by using classes. The type parameters are bounded to the class that realizes the parameterized class. In other words, the datatypes of the type parameters are defined in the classes that realize the parameterized class. Consider an example where you need to create a class for maintaining a list of items. It should be possible to use the same class to maintain a list of integers, a list of strings, or a list of products. In such a case you can create the class as a parameterized class.

In the preceding example, each entry corresponding to a product will include the product ID and the product name.
To use the functions of the parameterized class, you need to pass different types of objects to instantiate the L i s tclass. An example of a parameterized class is C# Generics. The following program segment in C# illustrates the realization of the L i s tparameterized class by using three different types, i n t e g e r , s t r i n g , and P r o d u c t , where P r o d u c tis a user-defined class containing two attributes, prod_id and prod_name. p u b l i cc l a s sL i s t < T > { p r i v a t eT [ ]l i s t=n e wT [ 5 ] ; p r i v a t ei n tn=0 ; / / N o .o fe l e m e n t si nl i s t p u b l i cv o i dA d d ( Ti n p u t ) { i f( n<5 ) l i s t [ n + + ]=i n p u t ; } } c l a s sT e s t L i s t { p r i v a t ec l a s sP r o d u c t { p r i v a t ei n tp r o d _ i d ; p r i v a t es t r i n gp r o d _ n a m e ; p u b l i cP r o d u c t ( i n ti d ,s t r i n gn a m e ) {
www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm 3/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

p r o d _ i d=i d ; p r o d _ n a m e=n a m e ; } } s t a t i cv o i dM a i n ( ) { / /D e c l a r eal i s to ft y p ei n t L i s t < i n t >l i s t 1=n e wL i s t < i n t > ( ) ; l i s t 1 . A d d ( 2 0 ) ; l i s t 1 . A d d ( 3 0 ) ; l i s t 1 . A d d ( 4 5 ) ; / /D e c l a r eal i s to ft y p es t r i n g L i s t < s t r i n g >l i s t 2=n e wL i s t < s t r i n g > ( ) ; l i s t 2 . A d d ( h e l l o ) ; l i s t 2 . A d d ( w e l c o m e ) ; l i s t 2 . A d d ( b y e ) ; / /D e c l a r eal i s to ft y p eE x a m p l e C l a s s L i s t < P r o d u c t >l i s t 3=n e wL i s t < P r o d u c t > ( ) ; P r o d u c tp 1=n e wP r o d u c t( 1 , B a k i n gP o w d e r ) ; P r o d u c tp 2=n e wP r o d u c t( 2 , S a l t ) ; P r o d u c tp 3=n e wP r o d u c t( 3 , S u g a r ) ; l i s t 3 . A d d ( p 1 ) ; l i s t 3 . A d d ( p 2 ) ; l i s t 3 . A d d ( p 3 ) ; } } You represent a parameterized class by a dashed rectangle that you place on the upper right corner of the class. The dashed rectangle contains the list of formal parameters using the syntax, name: type. The following figure shows the class, L i s t , with its formal parameters of the type, P.

Factory Class
www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm 4/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

A class that has multiple objects having the same attribute values is known as a factory class. To represent the multiple objects of a factory class, you can use a symbol of overlapping rectangles, as shown in the following figure.

An example of a factory class is an EJB factory class that creates multiple instances of EJB in an instance pool of the J2EE middle tier server. Multiple instances are used whenever requests for the same arrive at the server.

Self-linked Class
A class that has objects, which fulfill more than one role, is called a self-linked class. The following figure shows the representation of a self-linked class.

Consider an example for a self-linked class. In an organization, if an employee, Stevens, acts as both, project manager and team leader, then the two positions are linked. The instances of Stevens in the E m p l o y e eclass are linked, as shown in the following figure.

Recursive Aggregation and Qualified Association Relationships


In addition to generalization, dependency, and association relationships, you can also represent the following relationships among classes and objects: Recursive aggregation Qualified association

Recursive Aggregation
Recursive aggregation is an association relationship between two objects of the same class. Consider an employee information system in which P r o j e c t M a n a g e rand D e v e l o p e rare two objects of the E m p l o y e eclass. The developer reports to the project manager. Therefore, the P r o j e c t M a n a g e r
www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm 5/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

and D e v e l o p e robjects of the E m p l o y e eclass share a recursive aggregation relationship, as shown in the following figure.

In the preceding figure, an object diagram depicts the recursive aggregation among the objects of the E m p l o y e eclass. You can also depict recursive aggregation in a class diagram as shown in the following figure.

Qualified Association
Qualified association is an association relationship that relates an object of a class to a particular object or a set of objects of another class. You use a value, known as qualifier, to distinguish the objects of one class from another. A qualifier can be an attribute of the class. For example, many students are associated to a university. To distinguish a particular student from other students, you need to map a particular enrolment number to the student. For this reason, the U n i v e r s i t yclass uses the E n r o l m e n tN u m b e rattribute of the S t u d e n tclass as the qualifier to distinguish a particular student from other students. The U n i v e r s i t yand S t u d e n tclasses share an association relationship, as shown in the following figure.

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

6/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

Derived Elements
In UML, a derived element, as the name suggests, can be derived from one or more other elements of the same type. It is logically redundant to depict a derived element in a design model. However, you can use the derived elements to model an explicit detailed design. To represent a derived element in a class diagram, you place a slash (/) before the name of the element. A derived element can be of two types: Derived attribute Derived association

Derived Attribute
You calculate the value of a derived attribute from the value of the other attributes of the object. The formula to calculate the derived attribute is represented as a constraint in the class diagram. For example, the E m p l o y e eclass may have D a t e O f B i r t hand A g eas attributes. The D a t e O f B i r t hattribute is used to derive the value of the A g eattribute. You use a dotted straight line with the term, < < d e r i v e > > , to represent the relationship between the D a t e O f B i r t hand A g eattributes. The following figure shows the representation of a derived attribute in a UML notation.

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

7/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

Derived Association
You can deduce a derived association from the other associations in a class diagram. For example, the E m p l o y e eclass is associated to the D e p a r t m e n tclass and the D e p a r t m e n tclass is a part of the O r g a n i z a t i o nclass. Therefore, the E m p l o y e eclass is also associated to the O r g a n i z a t i o n class. You can derive this association from the associations between the D e p a r t m e n tand E m p l o y e e classes and the O r g a n i z a t i o nand D e p a r t m e n tclasses. The following figure shows the representation of a derived association in a UML notation.

Just a minute:

Which of the following is an association relationship between two objects of the same class? 1. Recursive aggregation 2. Derived association 3. Qualified association 4. Derived attribute Answer: 1. Recursive aggregation

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

8/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

Identifying Interfaces
An interface is a collection of operations that are used to represent the services provided by a class or component. An interface provides the declaration of only the public methods and does not provide their implementation. As a result, interfaces do not contain attributes.

Type classes can contain attributes and represent a group of objects in a similar domain. Conversely, an interface consists of only public methods and represents the specification of a service.
Interfaces are similar to classes. Like classes, interfaces are also contained in a package. However, you cannot create objects of interfaces. To create an interface, you need to identify the methods that are interdependent and group them using interfaces. This enhances the maintenance and reusability of the system.

Creating Interfaces
In UML, an interface is represented as a circle. Each interface has a unique name that is prefixed with the name of the package in which it is contained. The following figure shows an interface with the package name.

Names of interfaces are usually prefixed with an I, to distinguish them from other elements, such as classes.
You can also represent an interface in the class notation, which contains the interface name by using the
www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm 9/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

keyword, < < i n t e r f a c e > > , and the method declarations. The following figure shows the interface, I A c c e p t C a r d , with its method declarations.

Like classes, interfaces participate in all the relationships, such as generalization and association. In addition, interfaces participate in the realization relationship. Multiple classes or components can realize interfaces to provide the functions specified in the interfaces. Consider the example of the CSS again. You need to define two classes, A c c e p t C r e d i t C a r dand A c c e p t E C r e d i t C a r d , to define the functions to accept a credit card and an e-credit card from customers. These classes should realize a common interface, I A c c e p t C a r d , because: The I A c c e p t C a r dprovides the specification to the user interface of the CSS. The specification of both the classes, A c c e p t C r e d i t C a r dand A c c e p t E C r e d i t C a r d , remain the same but differ in implementation. The I A c c e p t C a r denables you to add another card, such as debit card, if required in the later stages, without the need to modify any of the existing classes. UML provides two notations to realize an interface: Lollipop notation: Shows the interface as a circle and displays the class that realizes the interface in a rectangle. The details of the operations contained in the interface or the class are not shown. The following figure shows how the A c c e p t C r e d i t C a r dclass realizes the interface, I A c c e p t C a r d .

Dashed arrow notation: Depicts an interface as a class with the help of the < < i n t e r f a c e > >keyword. The diagram also specifies the operations of the interfaces. A dashed arrow connects the class that realizes the interface with the interface. The following figure shows how the A c c e p t C r e d i t C a r dclass uses the dashed arrow notation to realize the interface, I A c c e p t C a r d .

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

10/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

You use the lollipop notation when a class that realizes the interface overloads the same methods as declared in the interface. You use the dashed arrow notation when either a few operations are overloaded or additional operations are declared in the class that realizes the interface.

Differentiating Abstract Classes from Interfaces


An abstract class and an interface both provide the specification of methods and do not allow you to create instances directly. The derived classes provide the implementations of the methods that the abstract classes and interfaces specify. Apart from this common behavior, there are some differences between an abstract class and an interface such as: Interfaces enable you to implement multiple inheritance because a class can implement more than one interface. However, abstract classes do not support multiple inheritance. A class cannot inherit more than one abstract class. An abstract class contains attributes and methods that can be public, private, or protected. An interface consists of only methods. An abstract class may provide the definition of some of its methods, but interfaces do not provide any definitions.
www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm 11/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

An abstract class is used in the same package as opposed to an interface that can be realized across multiple packages. You can use an abstract class when the derived classes have common attributes and operations. For example, in the CSS, you can create the classes, USD and Euro, to provide the functions to accept cash from the customer in Euro and USD. You can derive these classes from an abstract class, A c c e p t C a s h , because of the following reasons: Euro and USD classes share common methods, such as C a l c u l a t e T o t a l A m o u n t ( ) , to calculate the total amount entered by the customer. The Euro class and USD classes have similar attributes, such as the name of the issuing authority and the counterfeit notes found. You can use the A c c e p t C a s habstract class to derive another currency class to provide the functions to accept another currency.

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

12/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

Activity: Modeling the Static View of the Bank ATM System

Problem Statement
Janes Technology has been assigned the task to create a prototype for the InfoSuper bank ATM system. The project manager of Janes Technology has created the following use case diagram for the prototype after gathering requirements from the InfoSuper bank.

The preceding use case diagram depicts that the customers of the InfoSuper bank can have savings and current accounts. The ATM system allows customers to withdraw cash after it validates the ATM card and PIN of customers. The ATM system also enables customers to change the PIN and obtain a transaction summary. To model the static view of the prototype, you need to create the following diagrams: Class diagram Object diagram Prerequisite : To perform this activity, you will need the BANK_ATM.vsd file, which you created in the activity Refining the System Definition for the Infosuper Bank ATM System of Chapter 4.

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

13/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

Solution
To model the static view of the prototype of the InfoSuper bank ATM system, you need to perform the following tasks: 1. 2. 3. 4. 5. 6. 7. Identify the classes for the prototype. Identify the attributes and their visibility. Identify the operations and their visibility. Identify the relationships among classes. Identify interfaces and their realization relationships. Create a Class diagram. Create an Object diagram.

Task 1: Identifying the Classes for the Prototype The classes for the prototype can be identified on the basis of the Use Cases and Actors of the prototype for the InfoSuper bank ATM system. For the implementation, it is necessary to map all the operations of classes to the functions of Use Cases, to implement the functions of the Use Cases in the implementation phase. The classes of the ATM system are: ATM ATMCard BankCustomer Account CurrentAccount SavingsAccount Transaction CardScanner DisplayScreen CashDispenser Task 2: Identifying the Attributes and their Visibility The following table lists the classes with their respective attributes.

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

14/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

Task 3: Identifying the Operations and their Visibility The following table lists the operations that the classes of the ATM system perform.

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

15/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

16/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

Typically, the operations of classes are assigned public visibility to enable the generalization and association relationships among classes. The classes of the ATM system need to interact with each other to achieve functions. Therefore, all the operations of the ATM system classes have been assigned public visibility.

The Account class only declares the CalculateInterestRate() operation. Therefore, it is an abstract class. The SavingsAccount and CurrentAccount classes implement the functions of the CalculateInterestRate() operation.

Task 4: Identifying the Relationships Among Classes More than one customer of the InfoSuper bank can use the card scanner, cash dispenser, and display screen. Similarly, a bank customer may have more than one account in InfoSuper bank. The one-to-many multiplicity relationship exists among the following pairs of classes of the InfoSuper bank ATM system: CardScanner and BankCustomer CashDispenser and BankCustomer DisplayScreen and BankCustomer BankCustomer and Account ATM and BankCustomer Account and Transaction DisplayScreen and Transaction Account and CashDispenser The one-to-one relationship exists among the following classes of the InfoSuper bank ATM system: ATM and CardScanner CardScanner and DisplayScreen The self-linked classes are: CardScanner ATMCard CashDispenser The classes, SavingsAccount and CurrentAccount, are the types of the Accountclass. They inherit the properties of the Account class to calculate the interest on each account. For this reason, the Accountclass has a generalization relationship with the CurrentAccount and SavingsAccount classes. The BankCustomer class has an association relationship with the CardScanner, DisplayScreen, and CashDispenser classes. The ATM class shares a composition relationship with the CashDispenser, DisplayScreen and CardScanner classes. Similarly, the BankCustomer class shares a composition relationship with the ATMCard class. The BankCustomer class also shares the aggregation relationship with the Account and Transaction classes. The following diagram depicts the InfoSuper bank ATM system.
www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm 17/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

Task 5: Identifying Interfaces and Realization Relationship The InfoSuper bank ATM system needs the following interfaces that correspond to the CardScanner, DisplayScreen, and CashDispenser classes: ICardScanner IDisplayScreen ICashDispenser The following diagram depicts the realization relationship between the CardScanner class and the ICardScanner interface.

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

18/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

Similarly, the CashDispenser class and ICashDispenser interface, the DisplayScreen class and IDisplayScreen interface shares a realization relationship. Task 6: Creating a Class Diagram To create a Class diagram, you need to perform the following tasks: 1. Create classes and assign attributes and operations. 2. Create relationships among classes. Task 6.1: Creating Classes and Assigning Attributes and Operations To create classes, you need to perform the following steps: 1. Select StartAll ProgramsMicrosoft OfficeMicrosoft Office Visio for Enterprise Architects . 2. Open the Bank_ATM Visio file. The Bank ATM model appears, as shown in the following figure.

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

19/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

3. Right-click the Iteration2 in the Model Explorer window, and select NewStatic Structure Diagram. The Static Structure-1 page with blank drawing page appears. 4. Click the UML Static Structure (Metric) stencil in the Shapes window. 5. Drag the Class symbol ( ) on the drawing page from the UML Static Structure (Metric) stencil, as shown in the following figure.

6. Double-click the Class1. The UML Class Properties dialog box appears. 7. Select Class from Categories section and type ATM in the Name text box, as shown in the following figure.

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

20/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

8. Select Attributes from Categories section in the UML Class Properties dialog box. 9. Type the Location in the Attribute column of Attribute section. 10. Select the C#::string and public from Type and Visibility drop-down list respectively, as shown in the following figure.

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

21/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

By default the Multiplicity in UML Class Properties dialog box appears 1. You have to select the multiplicity according to the type of relationship between the classes.
11. 12. 13. 14. Similarly specify the other attributes of the ATM class. Select Operations from Categories section in the UML Class Properties dialog box. Type Show in the Operation column of Operations section. Select C#::void and public from Return Type and Visibility drop-down list respectively, as shown in the following figure.

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

22/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

15. Click the OK button. The ATM class appears as shown in the following figure.

If the data type of an attribute is a class, you need to make sure that referred class is created before referring it.

If an operation in a class accepts parameters, you need to define these parameters at the time of creating the operation. For this, double-click the class and select the Operations from Categories section of the UML Class Properties dialog box. Click the Properties button. The UML
www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm 23/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

Operation Properties dialog box appears. Select Parameters from Categories and specify the details of the parameters in the Parameters section that appears.
16. Similarly, create all the following classes of the InfoSuper bank ATM system. A T M C a r d A c c o u n t C u r r e n t A c c o u n t S a v i n g s A c c o u n t T r a n s a c t i o n C a r d S c a n n e r D i s p l a y S c r e e n C a s h D i s p e n s e r B a n k C u s t o m e r After creating all the classes, the Class diagram should appear as shown in the following figure.

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

24/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

Task 6.2: Creating Relationships among Classes To create relationships among classes, you can use various symbols available in the UML Static Structure (Metric) stencil. The following table lists the various relationship symbols available in Visio with their names.

To create a relationship between two classes, you need to perform the following steps: 1. Drag the Composition symbol from the UML Static Structure (Metric) and join the ATM and CardScanner classes, as shown in the following figure.

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

25/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

2. Double-click the Composition symbol to set the multiplicity and the relationship name. The UML Association Properties dialog box appears. 3. Select the Association from the Categories section. 4. Type Contains in the Name text box and specify the multiplicity value as 1 for each end of the association in the Multiplicity column of Association Ends section, as shown in the following figure.

The following figure shows the relationship between A T Mand C a s h S c a n n e rclass displaying the relationship name and the multiplicity at both ends.

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

26/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

If the name or the multiplicity of the relationship is not displayed, then right-click the relationship symbol and select Shape Display Options. The UML Shape Display Options dialog box appears. Select Name check box in the General options section and select End Multiplicities check box in the End options section, and click the OK button.
Similarly, draw the relationships between all other classes. The final class diagram should appear as shown in the following figure.

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

27/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

The UML Static Structure stencil does not contain a symbol for aggregation. You can create the symbol for aggregation by using the Composition symbol. When two classes need to be connected using the aggregation relationship, first connect them using the Composition symbol. Double-click the Composition symbol to open the UML Association Properties dialog box. Select Association from Categories section. Select the desired end to Shared in the Aggregation drop-down list of the Association section.

To convert an undirected relationship into a directed relationship, you need to


www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm 28/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

double-click the relationship symbol to open the UML Association Properties dialog box. Select Association from Categories section. Select the IsNavigable check box for the desired end in the Association Ends section.

Task 7: Creating an Object Diagram To create an Object diagram for the ATM system, you need to perform the following steps: 1. Right-click the Iteration2 in the Model Explorer window, and select NewStatic Structure Diagram. The Static Structure-1 page with blank drawing page appears. 2. Drag the Object symbol ( ) on the drawing page from the UML Static Structure (Metric) stencil, as shown in the following figure.

3. Double-click the Object1. The UML Object Properties dialog box appears. 4. Type ATM01 in the Name text box. 5. Select the class Iteration3::ATM from the Class drop-down list, as shown in the following figure.

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

29/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

6. Select the Attribute Values from Categories section and type the initial values California and Churchgate in the Value column for the Location and BranchName attributes respectively, as shown in the following figure.

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

30/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

7. Click the OK button. The ATM01 Object for the ATM class appears as shown in the following figure.

8. Right-click the ATM01:ATM and select Shape Display Options option, to remove the displayed datatypes of the attributes. The UML Shape Display Options dialog box appears. 9. Clear the Attribute Types check box in the General options section of the UML Shape Display Options dialog box and click the OK button. The Object diagram appears as shown in the following figure.

10. Similarly, draw the objects for all the following classes: A T M C a r d B a n k C u s t o m e r S a v i n g s A c c o u n t T r a n s a c t i o n C a r d S c a n n e r D i s p l a y S c r e e n C a s h D i s p e n s e r 11. Drag the Link symbol ( ) on the drawing page from the UML Static Structure (Metric) stencil to create relationships between the ATM01:ATM and CS:CardScanner objects, as shown in the following figure.

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

31/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

After adding all the objects and the relationships, the Object diagram should appear as shown in the following figure.

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

32/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

In Visio, Link symbol ( between objects.

) is used to represent the relationships

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

33/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

Summary
In this chapter, you learned that: An abstract class is a class that does not have any direct instances. An abstract class is used to define the common features and common behavior of a set of subclasses. A parameterized class, also called template class, provides a mechanism that enables you to use operations and classes to work with different data types. The objects of a parameterized class cannot be created. A class that has multiple objects having the same attribute values is known as a factory class. A class that has objects, which fulfill more than one role, is called a self-linked class. In addition to generalization, dependency, and association relationships, you can also represent the following relationships among classes and objects: Recursive aggregation Qualified association A derived element can be derived from one or more other elements of the same type. An interface is defined as a collection of operations that specifies a particular service of a class or a component.

Exercises

Exercise 1
To enhance the existing functionality of the Real Estate Management System, Blue Valley Consulting Inc. has decided to incorporate an additional module. The details of this module are as follows: Module: Import Data External partners responsibilities include maintaining and leasing properties and providing data and revenues as per their agreement with Blue Valley Consulting Inc. Each entry in the data that an external partner provides will consist of the amount that the external partner is rendering to Blue Valley Consulting along with the dates on which this amount will be paid. The Real Estate Management System imports and records this information. The system will import the data from a location, which will be specified by the Operations Manager. The system will ensure that the Operations Manager is notified whenever the external partner sends new data. It will prompt the Operations Manager to specify the location of the data. When the Operation Manager specifies the location of data that needs to be imported, the system will validate it. If the new data is validated, it will be associated with the property. The system, then, will ask the Operations Manager for approval for attaching the data to the Real Estate Management System. If the new data is not validated, the system will ask the Operations Manager to provide an alternative location for the data or exit from the module in case the Operations Manager does not want to provide a location.
www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm 34/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

Identify the classes and their components that are required to implement the Real Estate Management System. In addition to import data functionality, you need to identify classes for tenant and capital details modules. Create a class diagram showing the different types of classes and their relationship. Hint: To complete this exercise, you need to use the Visio file that you created for Exercise 1 of Chapter 4.

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

35/36

7/18/12

Object-Oriented Analysis and Design Using UML: Student Guide

Reference Links

Identifying Types of Classes and Relationships between Classes Identifying Interfaces


Reference Reading: Books The Unified Modeling Language Reference Manual by Grady Booch James RumBaugh Ivar Jacobson Publisher: Pearson Education Reference Reading: URLs http://www.smartdraw.com/resources/centers/ uml/uml2.htm#whatclass

www.niitstudent.com/india/Content/063OUML1S1/OEBPS/12_ch06.htm

36/36

Potrebbero piacerti anche