Lab. 02 - University of Engineering and Technology, Taxila

38
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING SOFTWARE ENGINEERING DEPARTMENT Software Design And Architecture 4th Semester-SE UET Taxila Lab. 02 Title: Working With Object Orientation and Relationships Lab Objective: Learn to Know How to model a class How to show a class's attributes and features How to discover classes How to model the connections among classes How to visualize class-subclass relationships How to show dependencies among classes Relations in StarUML Use of StarUML in visualizing Classes Tool used: StarUML Class: A class is a category or group of things that have the same attributes and the same behaviors. Visualizing a Class A rectangle is the icon that represents a class in the UML. The name of the class is, by convention, a word with an initial uppercase letter. It appears near the top of the rectangle. If your class has a two- word name, join the two words together and capitalize the first letter of the second word (as in WashingMachine in Fig 1). Fig 1:The UML class icon Attributes An attribute is a property of a class. It describes a range of values that the property may hold in objects (that is, in instances) of that class. A class may have zero or more attributes. By convention, a one-word attribute name is written in lowercase letters. If the name consists of more than one word, the words are joined and each word other than the first word begins with an uppercase

Transcript of Lab. 02 - University of Engineering and Technology, Taxila

Page 1: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

Lab. 02

Title: Working With Object Orientation and Relationships

Lab Objective: Learn to Know

How to model a class

How to show a class's attributes and features

How to discover classes

How to model the connections among classes

How to visualize class-subclass relationships

How to show dependencies among classes

Relations in StarUML

Use of StarUML in visualizing Classes

Tool used: StarUML

Class:

A class is a category or group of things that have the same attributes and the same behaviors. Visualizing a Class A rectangle is the icon that represents a class in the UML. The name of the class is, by convention, a word with an initial uppercase letter. It appears near the top of the rectangle. If your class has a two-word name, join the two words together and capitalize the first letter of the second word (as in WashingMachine in Fig 1).

Fig 1:The UML class icon

Attributes

An attribute is a property of a class. It describes a range of values that the property may hold in objects

(that is, in instances) of that class. A class may have zero or more attributes.

By convention, a one-word attribute name is written in lowercase letters. If the name consists of more

than one word, the words are joined and each word other than the first word begins with an uppercase

Page 2: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

letter. The list of attribute names begins below a line separating them from the classname, as Fig 2

shows.

Fig 2: Class and its attributes

Every object of the class has a specific value for every attribute. Fig 3 presents an example. Note that an

object's name begins with a lowercase letter, precedes a colon that precedes the classname, and the

whole name is underlined.

Fig 3: An object has a specific value for every one of its class's attributes

The UML gives you the option of indicating additional information for attributes. In the icon for the class,

you can specify a type for each attribute's value. Possible types include string, floating-point number,

integer, and Boolean (and other enumerated types). To indicate a type, use a colon to separate the

attribute name from the type. You can also indicate a default value for an attribute. Fig 4 shows these

ways of specifying attributes.

Page 3: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

Fig 4: An attribute can show its type as well as a default value

Operations

An operation is something a class can do, and hence it is something that you (or another class) can ask

the class to do. Like an attribute name, an operation's name is all in lowercase if it's one word. If the

name consists of more than one word, join the words and begin all words after the first with an

uppercase letter. The list of operations begins below a line that separates the operations from the

attributes, as in Fig 5.

Fig 5: The list of a class's operations appears below a line that separates them from the class's attributes.

Just as you can indicate additional information for attributes, you can indicate additional information for

operations. In the parentheses that follow an operation name, you can show the parameter that the

operation works on, along with that parameter's type. One kind of operation, the function, returns a

value after it finishes doing its work. For a function, you can show the value it returns and that value's

type.

Page 4: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

These pieces of information about an operation are called the operation's signature. Fig 6 shows a

couple of ways to represent the signature. The first two operations show the type of the parameter. The

third and fourth show the type of the return value.

Fig 6: Signatures for operations

In UML, a multiword classname has initial capital letters for all the words and

eliminates white space between each word (for example, WashingMachine).

Attribute names and operation-names follow the same convention, but the first

letter of the first word isn’t capitalized (for example, acceptClothes ()).

Associations

When classes are connected together conceptually, that connection is called an association.

Let's examine one—the association between a player and a team. You can characterize this association

with the phrase "a player plays on a team." You visualize the association as a line connecting the two

classes, with the name of the association ("Plays on") just above the line. You show how to read the

relationship with a filled triangle pointing in the appropriate direction. Figure 1 shows how to visualize

the Plays on association between the player and the team.

Figure 1: An association between a player and a team.

Page 5: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

When one class associates with another, each one usually plays a role within that association. You can

show each class's role by writing it near the line next to the class. In the association between a player

and a team, if the team is professional, it's an employer and the player is an employee. Figure 2 shows

how to represent these roles.

Figure 2. In an association, each class typically plays a role. You

can represent those roles on the diagram.

You can imagine an association that you could read in the other direction: A team employs players. You

can show both associations in the same diagram, with a filled triangle indicating how to read each

association, as in Figure 3.

Figure 3: Two associations between classes can appear on the same diagram.

Associations may be more complex than just one class connected to another. Several classes can

connect to one class. If you consider guards, forwards, and centers, and their associations with the Team

class, you'll have the diagram in Figure 4.

Page 6: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

Figure 4: Several classes can associate with a particular class.

Constraints on Associations

Sometimes an association between two classes has to follow a rule. You indicate that rule by putting a

constraint near the association line. For example, a Bank Teller serves a Customer, but each Customer is

served in the order in which he or she appears in line. You capture this in the model by putting the word

ordered inside curly brackets (to indicate the constraint) near the Customer class, as in Figure 5.

Figure 5.You can place a constraint on an association. In this example, the Serves association is

constrained to have the Bank Teller serve the Customer in order.

Another type of constraint is the Or relationship, signified by {or} on a dashed line that connects two

association lines. Figure 6 models a high school student choosing either an academic course of study or a

commercial one.

Page 7: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

Figure 6. The Or relationship between two associations is a constraint.

Association Classes

An association can have attributes and operations, just like a class. In fact, when this is the case, you

have an association class. You visualize an association class the same way you show a regular class, and

you use a dashed line to connect it to the association line. An association class can have associations to

other classes. Figure7 shows an association class for the Plays on association between a player and a

team. The association class, Contract, is associated with the GeneralManager class.

Figure 7. An association class models an association’s attributes and operations. It’s connected to an

association via dashed line and can associate with another class.

Links

Page 8: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

Just as an object is an instance of a class, an association has instances as well. If you imagine a specific

player who plays for a specific team, the Plays on relationship is called a link, and you represent it as a

line connecting two objects. Just as you would underline the name of an object, you underline the name

of a link, as in Figure 8.

Figure 8. A link is an instance of an association. It connects objects rather than classes. In a link, you

underline the name of the link, just as you underline the name of an object.

Multiplicity

The association drawn so far between Player and Team suggests that the two classes are in a one-to-one

relationship. Common sense tells you that this isn't the case, however. A basketball team has five

players (not counting substitutes). The Has association must take this into account. In the other

direction, a player can play for just one team, and the Plays on association must account for that. These

specifications are examples of multiplicity—the number of objects from one class that relate with a

single object in an associated class. To represent these numbers in the diagram, you place them near the

appropriate class, as in Figur9. (The numbers can go either above or below the association line.)

Figure 9. Multiplicity denotes the number of objects of one class that can relate to one object of an

associated class.

Page 9: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

The multiplicity in this example is not the only type. A variety of multiplicities are possible (a

multiplicity of multiplicities, so to speak). One class can relate to another in a 1-to-1, 1-tomany, 1-to-1 or

more, 1-to-0 or one, 1-to-a bounded interval (for example, 1-to-5 through

10), 1-to-exactly n (as in this example), or 1-to-a set of choices (for example, one-to-nine or ten).

The UML uses an asterisk (*) to represent more and to represent many. In one context Or isrepresented

by two dots, as in 1..* ("one or more"). In another context, Or is represented by a comma, as in 5,10 ("5

or 10"). Figure 10 shows how to visualize possible multiplicities. (Note that the phrase at the right of

each multiplicity in Figure 10 isn't part of the UML. It's just a label I added to help clarify things.)

Page 10: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

Figure 10. Possible multiplicities and how to represent them in the UML.

Qualified Associations

When an association's multiplicity is one-to-many, a particular challenge often arises: lookup. When an

object from one class has to choose a particular object from another in order to fulfill a role in an

association, the first class has to rely on a specific attribute to select the correct object. That attribute is

typically an identifier, such as an ID number. For example, a hotel's reservation list has many

reservations, as Figure 11 shows.

Figure 11. A reservation list and its reservations are in a one-to many multiplicity.

Figure 12.The UML notation for a qualifier. The idea is that when you add that little rectangle, you

qualify the association.

Page 11: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

When you make a reservation at a hotel, the hotel assigns you a confirmation number. If you call with

questions about the reservation, you have to supply the confirmation number, so that someone looking

through the reservation list can select your reservation.

In the UML, the ID information is called a qualifier. Its symbol is a small rectangle adjoining

the class that has the "one" part in the one-to-many multiplicity. Figure12 shows the representation.

Although the multiplicity between ReservationList and Reservation is one-to-many, the multiplicity

between confirmationNumber and Reservation is one-to-one.

Reflexive Associations

Sometimes, a class is in an association with itself. Referred to as a reflexive association, this can happen

when a class has objects that play a variety of roles. For example, a CarOccupant can be either a driver

or a passenger. In the role of the driver, one CarOccupant drives zero or more additional CarOccupants

who play the role of passenger. You represent this by drawing an association line from the class

rectangle back to the same

class rectangle, and on the association line you indicate the roles, name of the association, direction of

the association, and multiplicity as before. Figure 13 presents this example.

Figure 13. In a reflexive association, you draw the line from the class to itself, and you can include the

roles, association name, direction of the association, and multiplicity.

Inheritance and Generalization

One of the hallmarks of object-orientation is that it captures one of the great commonsense

Page 12: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

aspects of day-to-day life: If you know something about a category of things, you automatically know

some information you can transfer to other categories. If you know something is an appliance, you

already know it has an on-off switch, a brand name, and a serial number. If you know something is an

animal, you take for granted that it eats, sleeps, has a way of being born, has a way of getting from one

place to another, and probably has a number of other attributes (and operations) you could list if you

thought about it for a few minutes.

Object-orientation refers to this as inheritance. The UML also refers to this as generalization. One class

(the child class or subclass) can inherit attributes and operations from another (the parent class or

superclass). The parent class is more general than the child class.

The inheritance hierarchy doesn't have to end at two levels: A child class can be a parent class for still

another child class. Mammal is a child class of Animal, and Horse is a child class of Mammal.

In the UML, you represent inheritance with a line that connects the parent class to the child class. On

the part of the line that connects to the parent class, you put an open triangle that points to the parent

class. This type of connection stands for the phrase is a kind of. A Mammal is a kind of Animal, and a

Horse is a kind of Mammal. Figure 14 shows this particular inheritance hierarchy, along with some

additional classes.

Figure 14. An inheritance hierarchy in the animal kingdom

Page 13: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

In the figure, note the appearance of the triangle and the lines when more than one child class inherits

from a parent class. Setting the diagram up this way results in a less busy diagram than showing all the

lines and triangles, but the UML doesn't prohibit putting all of them in the picture. Note also that you

don't put the inherited attributes and operations in

the subclass rectangles, as you've already represented them in the superclass. Child classes add to the

attributes and operations they inherit. For example, a Mammal has hair and gives milk, two attributes

not found in the Animal class. A class might have no parents, in which case it's a base class or root class.

A class might have no children, in which case it's a leaf class. If a class has exactly one parent, it has

single inheritance. If a class has more than one parent, it has multiple inheritance.

Abstract Classes

In the basketball model, the class—Player is useful because it serve as parent class for important child

class. The child classes are important in the model because you'll ultimately want to have instances of

these classes. To develop the model you'll need instances of Guard, Forward, Center, GameClock, and

ShotClock. Player and , however, will not provide any instances for the model. An object from the Player

class would serve no purpose.

Classes like Player are said to be abstract. You indicate an abstract class by writing its name in italics.

Figure 15 shows the abstract class and children.

Figure 15.Inheritance hierarchy with abstract class in the basketball model.

Dependencies

In a different kind of relationship, one class uses another. This is called a dependency. The

Page 14: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

most common usage of a dependency is to show that the signature of one class's operation uses

another class.

Suppose you're designing a system that displays corporate forms on-screen so employees can fill them

out. The employee uses a menu to select the form to fill out. In your design, you have a System class and

a Form class. Among its many operations, the System class has displayForm(f:Form). The form the

system displays obviously depends on which form the user selects. The UML notation for this is a dashed

line with an arrowhead pointing at the class depended on, as in Figure 16.

Figure 16. A dashed line with an arrowhead represents a dependency.

Modeling With StarUML

StarUML™ supports 11 UML diagram types. The user can freely create and manage different diagrams as needed.

1. After starting SU, a template box titled "New Project by Approach" may be present: if it is, select "Default Approach" and press "Ok".

Page 15: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

2. Open a New project. 3. You will find the following window.

Modeling with Class Diagram

The following elements are available in the class diagram.

Subsystem Package Class Interface Enumeration Signal

Page 16: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

Exception Port Part Association DirectedAssociation Aggregation Composition Generalization Dependency Realization AssociationClass Connector Object Link

Class

Semantics

A class is the descriptor for a set of objects with similar structure, behavior, and relationships.

Procedure for creating class

In order to create class,

1. Click [Toolbox] -> [Class] -> [Class] button.

2. And click at the position where class will be placed in the [main window].

Page 17: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

3. A new class is created on the diagram and class quick dialog is opened.

4. At the quick dialog, enter the class name and press [Enter] key.

Proceudre for adding attribute

There are three method to add attribute to class.

using quick dialog

using model in the [main window] or the [model explorer]

using [collection editor]

In the case of using quick dialog,

1. Double-click class.

2. Press [Add Attribute] button at the quick dialog, and you can add attribute.

In the case of using model,

1. Select class in the [main window] or in the [model explorer].

2. Right-click the selected class, select [Add] -> [Attribute] popup menu, and you can do.

In the last case,

Page 18: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

1. Select [Collection Editor...] popup menu.

2. Or click button in [attributes] property on properties window.

Page 19: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

3. At [attribute] tab of the [collection editor], you can add attribute by using button.

Proceudre for adding operation

There are three method to add attribute to class.

using quick dialog

using model in the [main window] or the [model explorer]

using [collection editor]

In the case of using quick dialog,

1. Double-click class and class quick dialog is shown.

2. Press [Add Operation] button at the quick dialog, and you can add operation.

Page 20: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

In the case of using model, select class in the [main window] or in the [model explorer], right-click the selected class, select [Add] -> [Operation] popup menu, and you can do.

In the last case,

1. Select [Collection Editor...] popup menu.

2. At [operations] tab of the [collection editor], you can add operation by using button.

Procedure for adding parameter to operationn

In order to add parameter to operation,

Page 21: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

1. Select operation in the [model explorer], select [Add] -> [Parameter] popup menu, and new parameter will be added.

2. Or select operation in the [model explorer], select [Collection Editor...] popup menu.

3. Or click button in [Parameters] property on properties window.

Page 22: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

4. At the [Parameters] tab of the [collection editor], you can add parameter by using button.

Activity 1:

You have been asked to design a Resource Management System for a consulting firm. This

system will be used to keep track of the time each employee spends working on a project.

Assume an employee works on only one project at any given time.

In the Resource Management System, each project is associated with one specific customer. A project is comprised of one or more activities. An activity consists of one or more tasks. Each task requires a certain skill and is assigned to a specific resource. Each resource has one or more skills. Skills have multiple levels of expertise. An employee can be either a salaried employee or an hourly employee.

Analysis and Design Process

1. Draw the Class Diagram for the system. a. Draw the nouns as classes.

2. Update the Class Diagram with class attributes. 3. Update the Class Diagram with class methods.

Activity 2:

Page 23: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

You have been asked to design a Student Registration System to replace the university’s legacy system. The system will allow students to register for courses and view grade reports. Each student has access to his or her course and grade information only and must be authenticated prior to viewing or updating the information.

A course instructor will use the system to view the list of courses he or she is assigned for a given semester or has taught previously, view the list of students registered for the course(s) he or she is teaching, and record final grades for each student in the course(s). TA assignments will also be viewable through this system. Instructors must also be authenticated prior to viewing or updating any information.

The Student Registration System will interface with several other systems including a system that manages the course catalog and another system that supports financial aid and billing tasks.

Follow the process documented below to design the Student Registration System.

Analysis and Design Process

1. Analyze the written requirements. a. Identify the nouns. Highlight or list the nouns your find in the requirements.

2. Draw the Class Diagram for the system. a. Draw the nouns as classes.

3. Update the Class Diagram with class attributes. 4. Update the Class Diagram with class methods.

Association

Semantics

An association is an association among exactly two classifiers (including the possibility of an association from a classifier to itself).

Procedure for creating association

In order to create association,

Page 24: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

1. Click [Toolbox] -> [Class] -> [Association] button.

2. Drag from one associated and drop to another in the [main window].

3. Between two classes, a new association is created as follows.

Procedure for adding qualifier to association

In order to add qualifier to association,

Page 25: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

1. Select association's [Collection Editor...] popup menu.

2. Or click button in [End.Qualifiers] property on properties window.

Page 26: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

3. At [Qualifiers] tab of the [collection editor], you can add qualifier to the association by using button.

4. The result is as follows.

Procedure for creating multiple classes related to current class at once

If you want to create Dog, Pig, Cat classes related to Me class

1. Double-click Me class or press [Enter] key. At quick dialog, enter as following.

Page 27: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

2. Then three classes with association are created as following.

DirectedAssociation

Procedure for creating directed association

Procedure for creating directed association is equal to association's.

1. Click [Toolbox] -> [Class] -> [DirectedAssociation].

Page 28: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

2. Drag and drop between two elements in arrow direction.

3. The result is as follows.

Procedure for changing association to directed association

To change association to directed association, click the arrow-opposite-side association end. At the quick dialog, uncheck navigable and association becomes directed.

Page 29: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

Procedure for creating element having directed association by shortcut creation syntax

In order to create element having directed association, use shortcut creation syntax,

1. Double-click element. At the quick dialog, enter name of elements that have directed association after "->" string and separate names with ",".

2. Press [Enter] key and multiple elements associated with selected element are created and arranged automatically.

Aggregation

Semantics

An aggregate is a more specific type of association. The aggregate is signified by a hollow diamond on the point where the association connects with the classifier (association end).

Procedure for creating aggregate

In order to create aggregation,

Page 30: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

1. Click [Toolbox] -> [Class] -> [Aggregation] button.

2. Drag from one associated and drop to another in the [main window].

3. The result is as follows.

Procedure for creating aggregated class by shortcut creation syntax

In order to create class aggregated to selected class, use shortcut creation syntax.

Page 31: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

1. Double-click to popup quick dialog. At the quick dialog, enter name of class aggregated to current class after "<>-" string and separate names with ",".

2. Press [Enter] key and classes aggregated to selected class are created and arranged automatically.

Composition

Semantics

A composite is a more specific type of association. The composite is signified by a filled diamond on the point where the association connects with the classifier (association end).

Procedure for creating composition

In order to create composition,

Page 32: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

1. Click [Toolbox] -> [Class] -> [Composition] button.

2. Drag from one class and drop to another class composed in the [main window].

3. Between two classes, a new composition relationship is created as follows.

Procedure for creating composing class by shortcut creation syntax

In order to create class composing selected class, use shortcut creation syntax.

Page 33: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

1. Double-click to popup quick dialog. At the quick dialog, enter name of class composing selected class after "<*>-" string and separate names with ",".

2. Press [Enter] key and classes composing selected class are created and arranged automatically.

Generalization

Semantics

Generalization is the taxonomic relationship between a more general element (the parent) and a more specific element (the child) that is fully consistent with the first element and that adds additional information. It is used for classes, packages, usecases, and other elements.

Procedure for creating generalization

In order to create generalization,

Page 34: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

1. Click [Toolbox] -> [Class] -> [Generalization] button.

2. Drag from child element and drop to parent element in the [main window].

3. Then a new generalization is created.

Procedure for creating multiple children classes at once.

In order to create multiple children classes inheriting selected class at once, use shortcut creation syntax.

Page 35: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

1. Double-click to popup quick dialog. At the quick dialog, enter name of class inheriting selected class after "<=" string and separate names with ",".

2. The children classes are created below selected class and arranged automatically.

3. From tool box select association class and connect it to association line.

Procedure for creating multiple parent classes at once

In order to create multiple parent classes of selected class at once, use shortcut creation syntax.

1. Double-click to popup quick dialog. At the quick dialog, enter name of parent classes of selected class after "=>" string and separate names with ",".

2. The parent classes are created above selected class and arranged automatically.

Page 36: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

Dependency

Semantics

A dependency indicates a semantic relationship between two model elements (or two sets of model elements). It relates the model elements themselves and does not require a set of instances for its meaning. It indicates a situation in which a change to the target element may require a change to the source element in the dependency.

Procedure for creating dependency

In order to create dependency,

1. Click [Toolbox] -> [Class] -> [Dependency] button.

2. Drag and drop between elements in the [main window] in depending direction.

Page 37: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

3. A new dependency between two classes is created.

Procedure for dependent element by shortcut creation syntax

In order to create element depending by selected element, use shortcut creation syntax.

1. Double-click to popup quick dialog. At the quick dialog, enter name of dependent elements by selected element after "-->" string and separate names with ",".

2. Press [Enter] key and dependent elements by selected class are created and arranged automatically.

Activity 1:

Page 38: Lab. 02 - University of Engineering and Technology, Taxila

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Software Design And Architecture 4th Semester-SE UET Taxila

You have been asked to design a Student Registration System to replace the university’s legacy system. The system will allow students to register for courses and view grade reports. Each student has access to his or her course and grade information only and must be authenticated prior to viewing or updating the information.

A course instructor will use the system to view the list of courses he or she is assigned for a given semester or has taught previously, view the list of students registered for the course(s) he or she is teaching, and record final grades for each student in the course(s). TA assignments will also be viewable through this system. Instructors must also be authenticated prior to viewing or updating any information.

The Student Registration System will interface with several other systems including a system that manages the course catalog and another system that supports financial aid and billing tasks.

Follow the process documented below to design the Student Registration System.

Analysis and Design Process

5. Analyze the written requirements. a. Identify the nouns. Highlight or list the nouns your find in the requirements. b. Identify the verbs. Highlight or list the verbs you find in the requirements.

6. Draw the Class Diagram for the system. a. Draw the nouns as classes. b. Draw the verbs as associations/relationships between classes. c. Assign a multiplicity to each association (i.e., one-to-one, one-to-many, many-to-many)

7. Update the Class Diagram with class attributes. 8. Update the Class Diagram with class methods.

Case Study

A laboratory has several chemists who work on one or more projects. Chemists (empid, Name, Phone_no) also may use certain kinds of equipments (Serial_no, cost) on each project (projected, start_date). The organization wishes to record assign-date i.e., the date when the given equipment item was assigned to a particular Chemist working on a specific project, as well as total number of hours the chemist has used the equipment for the project. The chemist must be assigned to at least one project and one equipment item. Draw the class diagram.