0% found this document useful (0 votes)
7 views12 pages

SDA Lab 2 2k23 Part 2

The document outlines a laboratory exercise focused on creating UML class diagrams, detailing the learning outcomes, assessment items, and key concepts such as classes, attributes, operations, associations, and generalization. It emphasizes the use of Star UML version 6 for modeling and provides instructions for adding elements like attributes and operations, as well as representing relationships such as aggregation and composition. The lab aims to equip students with practical skills in software design and architecture through hands-on experience.

Uploaded by

Nabeel Chaudhry
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views12 pages

SDA Lab 2 2k23 Part 2

The document outlines a laboratory exercise focused on creating UML class diagrams, detailing the learning outcomes, assessment items, and key concepts such as classes, attributes, operations, associations, and generalization. It emphasizes the use of Star UML version 6 for modeling and provides instructions for adding elements like attributes and operations, as well as representing relationships such as aggregation and composition. The lab aims to equip students with practical skills in software design and architecture through hands-on experience.

Uploaded by

Nabeel Chaudhry
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Software Design and Architecture

Laboratory # 02

1/27/2025
UET TAXILA
Engr. Sidra Shafi

CLO Learning Outcomes Assessment Item BT Level PLO


No.
1 Construct the experiments / projects Lab Task, Mid Exam,
of varying complexities. Final Exam, Quiz,
P2 / C2 3
Assignment, Semester
Project
2 Use modern tool and languages. Lab Task, Semester
P2 5
Project
3 Demonstrate an original solution of Lab Task, Semester
A2 8
problem under discussion. Project
4 Work individually as well as in teams Lab Task, Semester A2 9
Project
Creating UML Class Diagrams
Statement Purpose:
After this Lab, students will be able to know:

• Creation of a class diagram


• How to model a class, its attributes, and operations
• How to represent association, aggregation, and composition
• How to represent inheritance
• How to represent dependency between classes

UML Tool: Star UML version 6.


Class Diagram:
In software engineering, a class diagram in the Unified Modeling Language (UML) is a type of
static structure diagram that describes the structure of a system by showing the system's classes,
their attributes, operations (or methods), and the relationships among objects.
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. Pascal casing is
used for giving names to classes.

Attributes:
An attribute is a property of a 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, camel casing is used.

The list of attribute names begins below a line separating them from the classname.

4th Semester UET TAXILA


Every object of the class has a specific value for every attribute. An object's name begins with a
lowercase letter, precedes a colon that precedes the classname, and the whole name is underlined.

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.

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.
Camel Casing is used for creating names for operations. The list of operations begins below a line
that separates the operations from the attributes.

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.

These pieces of information about an operation are called the operation's signature.

With PascalCase, the first letter of every word in the identifier is upper case. With camelCase,
the first letter of the first word in the identifier is lower case, while the first letter of every
subsequent word is uppercase.

Associations

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

This kind of relationship represents static relationships between classes A and B. For example, an
employee works for an organization.

In this example, the relationship between student and college is shown which is studies.

4th Semester UET TAXILA


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

A constraint specifies conditions that must be held true for the model to be well-formed.A
constraint is rendered as a string enclosed by brackets and placed near the associated element.

If you want to specify your semantics more precisely, you can use the UML’s Object Constraint
Language (OCL) as shown in the following class diagram:

Association classes allow you to add attributes, operations, and other features to associations, as
shown in Figure.

4th Semester UET TAXILA


We can see from the diagram that a Person may work for a single Company. We need to keep
information about the period of time that each employee works for each Company.
We can do this by adding a dateRange attribute to the association. We could add this attribute to
the Person class, but it is really a fact about a Person's relationship to a Company, which will
change should the person's employer change.

Link:

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.

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,

For example, multiple patients are admitted to one hospital.

4th Semester UET TAXILA


The multiplicity in this example is not the only type. A variety of multiplicities are possible.
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, or 1-to-a set of choices (for example,
one-to-nine or ten).

Generalization:

Generalization is a mechanism for combining similar classes of objects into a single, more general
class. Generalization identifies commonalities among a set of entities. The commonality may be
of attributes, behavior, or both. In other words, a superclass has the most general attributes,
operations, and relationships that may be shared with subclasses. A subclass may have more
specialized attributes and operations.
Specialization is the reverse process of Generalization means creating new sub-classes from an
existing class.

For Example, a Bank Account is of two types - Savings Account and Credit Card Account.
Savings Account and Credit Card Account inherit the common/ generalized properties like
Account Number, Account Balance, etc. from a Bank Account and also have their specialized
properties like unsettled payment etc.

4th Semester UET TAXILA


Abstract Classes in UML: You indicate an abstract class by writing its name in italics.

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

A class depends on B class

Modeling in Star UML:

Click on class and then click on Main Window.

Adding Attributes:

For example, in Student class attributes are added by

• double clicking class name and selecting attribute,


• right click and select Add-> Attribute,
• right click ->Collection Editor-> Add Attribute

4th Semester UET TAXILA


Adding Operations: Operations are also added using the same three options.

4th Semester UET TAXILA


Operation Parameters:

4th Semester UET TAXILA


Right click model explorer and select collections editor.

Steps for creating association:

Select association from toolbox

Drag from one associated class and drop to another.

Adding qualifier:
Right click on association-> Collection Editor -> Qualifier

Directed Association:
Select directed association symbol from toolbox. Drag and drop between two elements in arrow
direction.

4th Semester UET TAXILA


Aggregation:
Aggregation is a special type of association that models a whole- part relationship between
aggregate and its parts. In UML, it is graphically represented as a hollow diamond shape on the
containing class end of the tree with a single line that connects the contained class to the containing
class.

Select the symbol.

Drag from one associated class and drop to another in the main window.

Composition:

The composition is a subset of aggregation. It portrays the dependency between the parent and its
child, which means if one part is deleted, then the other part also gets discarded. It represents a
whole-part relationship.

The UML representation of a composition relationship shows composition as a filled diamond


shape on the containing class end of the lines that connect contained class(es) to the containing
class.

In staruml, select the composition symbol from toolbox.

Drag from one contained class and drop to another container class.

4th Semester UET TAXILA


Generaliation:
It is simply inheritance.

In staruml, select the generalization symbol from toolbox.

Drag from subclass and drop to superclass.

Dependency:
It indicates a situation in which a change to the target element may require a change to the source
element in the dependency.

In staruml, select the dependency symbol from toolbox.


Drag and drop the symbol between elements in the in depending direction.

*******************

4th Semester UET TAXILA

You might also like