You are on page 1of 13

LAB MANUAL SOFTWARE DESIGN AND ARCHITECTURE

Lab: 7

Object Oriented Analysis:


Discovering Classes

SE4th FICT BUITEMS


AB LAB MANUAL SOFTWARE DESIGN AND ARCHITECTURE

LAB No 7__________________________________________________02/06/2023

1. Objectives:

After completing this lab, Students will be able to;

 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

2. Corresponding CLO and PLO:


 CLO 1, PLO 3
3. Theory:

Introduction:
The class diagram is a static diagram. It represents the static view of an application. Class
diagram is not only used for visualizing, describing, and documenting different aspects of a system but also for
constructing executable code of the software application.
The class diagram describes the attributes and operations of a class and also the constraints
imposed on the system. The class diagrams are widely used in the modeling of object oriented systems
because they are the only UML diagrams which can be mapped directly with object oriented languages.
The class diagram is a model for creating the classes, their attributes, and functions.
In class diagram, each class have three parts
1. Class name
2. Attributes of the class
3. Functions of the class

Definition:
The class diagram shows a collection of classes, interfaces, associations, collaborations and
constraints. It is also known as a structural diagram.

Purpose:
The purpose of the class diagram is to model the static view of an application. The class diagrams
are the only diagrams which can be directly mapped with object oriented languages and thus widely used at the
time of construction. Class diagrams are the most popular UML diagram in the coder community.
AB LAB MANUAL SOFTWARE DESIGN AND ARCHITECTURE

The purpose of the class diagram can be summarized as:


 Analysis and design of the static view of an application.
 Describe responsibilities of a system.
 Base for component and deployment diagrams.
 Forward and reverse engineering.
What is a Class ?
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

A description of a group of objects all with similar roles in the system, which consists of:
 Structural features (attributes) define what objects of the class "know"
o Represent the state of an object of the class
o Are descriptions of the structural or static features of a class
 Behavioral features (operations) define what objects of the class "can do"
o Define the way in which objects may interact
o Operations are descriptions of behavioral or dynamic features of a class
Class Notation:
A class notation consists of three parts:
1. Class Name
 The name of the class appears in the first partition.
2. Class Attributes
 Attributes are shown in the second partition.
 The attribute type is shown after the colon.
 Attributes map onto member variables (data members) in code.
3. Class Operations (Methods)
 Operations are shown in the third partition. They are services the class provides.
 The return type of a method is shown after the colon at the end of the method signature.
AB LAB MANUAL SOFTWARE DESIGN AND ARCHITECTURE

 The return type of method parameters is shown after the colon following the parameter
name.
 Operations map onto class methods in code

The graphical representation of the class - MyClass as shown above:


 MyClass has 3 attributes and 3 operations
 Parameter p3 of op2 is of type int
 op2 returns a float
 op3 returns a pointer (denoted by a *) to Class6

Class Relationships:
A class may be involved in one or more relationships with other classes. A relationship can be one of the
following types: (Refer to the figure on the right for the graphical representation of relationships).
Relationship Type Graphical Representation

Inheritance (or Generalization):
 Represents an "is-a" relationship.
 An abstract class name is shown in italics.
 SubClass1 and SubClass2 are specializations
of Super Class.
 A solid line with a hollow arrowhead that
point from the child to the parent class

Simple Association:
AB LAB MANUAL SOFTWARE DESIGN AND ARCHITECTURE

 A structural link between two peer classes.


 There is an association between Class1 and
Class2
 A solid line connecting two classes

Aggregation:
A special type of association. It represents a "part of"
relationship.
 Class2 is part of Class1.
 Many instances (denoted by the *) of Class2
can be associated with Class1.
 Objects of Class1 and Class2 have separate
lifetimes.
 A solid line with an unfilled diamond at the
association end connected to the class of
composite

Composition:
A special type of aggregation where parts are
destroyed when the whole is destroyed.
 Objects of Class2 live and die with Class1.
 Class2 cannot stand by itself.
 A solid line with a filled diamond at the
association connected to the class of
composite
AB LAB MANUAL SOFTWARE DESIGN AND ARCHITECTURE

Dependency:
 Exists between two classes if the changes to
the definition of one may cause changes to the
other (but not the other way around).
 Class1 depends on Class2
 A dashed line with an open arrow

Relationship Names
 Names of relationships are written in the middle of the association line.
 Good relation names make sense when you read them out loud:
 "Every spreadsheet contains some number of cells",
 "an expression evaluates to a value"
 They often have a small arrowhead to show the direction in which direction to read the
relationship, e.g., expressions evaluate to values, but values do not evaluate to expressions.

Relationship - Roles
 A role is a directional purpose of an association.
 Roles are written at the ends of an association line and describe the purpose played by that class
in the relationship.
 E.g., A cell is related to an expression. The nature of the relationship is that the
expression is the formula of the cell.
Visibility of Class attributes and Operations
In object-oriented design, there is a notation of visibility for attributes and operations. UML identifies four

types of visibility: public, protected, private, and package.

The +, -, # and ~ symbols before an attribute and operation name in a class denote the visibility of the attribute

and operation.
 + denotes public attributes or operations
AB LAB MANUAL SOFTWARE DESIGN AND ARCHITECTURE

 - denotes private attributes or operations


 # denotes protected attributes or operations
 ~ denotes package attributes or operations

Where to use class diagrams:


Class diagram is also considered as the foundation for component
and deployment diagrams. Class diagrams are not only used to visualize the static view of the system but they are
also used to construct the executable code for forward and reverse engineering of any system.
Generally UML diagrams are not directly mapped with any object oriented programming languages but
the class diagram is an exception.
Class diagram clearly shows the mapping with object oriented languages like Java, C++ etc. So class
diagram is generally used for construction purpose.

Class diagrams are used for:


 Describing the static view of the system.
 Showing the collaboration among the elements of the static view.
 Describing the functionalities performed by the system.
 Construction of software applications using object oriented languages.

Equipment’s:
 StarUML
 Rational rose
 Enterprise architecture
Procedure:
How to draw class diagrams:
Class diagrams are the most popular UML diagrams used for construction of software applications.
Class diagram is basically a graphical representation of the static view of the system and represents different
aspects of the application. So a collection of class diagrams represent the whole system.

The point ponders while drawing a class diagram is:


 The name of the class diagram should be meaningful to describe the aspect of the system.
 Each element and their relationships should be identified in advance.
 Responsibility (attributes and methods) of each class should be clearly identified.
 For each class minimum number of properties should be specified. Because unnecessary properties will
make the diagram complicated.
 Use notes when ever required to describe some aspect of the diagram. Because at the end of the drawing
it should be understandable to the developer/coder.

Observations:

Lab Tasks/Assignment:
Task 1:
Scenario:
AB LAB MANUAL SOFTWARE DESIGN AND ARCHITECTURE

A company consists of departments. Departments are located in one or more offices. One office act as a
headquarter. Each department has a manager who is recruited from the set of employees. Your task is to
model the system for the company.
Task:
Draw a class diagram which consists of all the classes in your system their attributes and operations,
relationships between the classes, multiplicity specifications, and other model elements that you find appropriate.

Task 2:
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


AB LAB MANUAL SOFTWARE DESIGN AND ARCHITECTURE

o Draw the Class Diagram for the system.


o Draw the nouns as classes.
o Update the Class Diagram with class attributes.
o Update the Class Diagram with class methods.

Task 3:
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

Analyze the written requirements.


Identify the nouns. Highlight or list the nouns your find in the requirements.
AB LAB MANUAL SOFTWARE DESIGN AND ARCHITECTURE

Draw the Class Diagram for the system.


Draw the nouns as classes.
Update the Class Diagram with class attributes.
Update the Class Diagram with class methods.
AB LAB MANUAL SOFTWARE DESIGN AND ARCHITECTURE

Task 4:
Draw class diagram of your system. Identify the attributes, operations and find relationships
between classes.

4. Equipment’s:
 Star UML
 Edraw Max
 GUI design Studio
 Balsamiq
5. Procedure:
AB LAB MANUAL SOFTWARE DESIGN AND ARCHITECTURE

1. Rubrics:
Absent Student is Student Student Student Student
unable to can has has perfectly
follow the understand followed constructe implemente
provided the instruction d the d a working
instructio provided s to functional/ model/
ns laboratory construct working logic/
properly. instruction the schematic/ circuit/
The s and fundament model/ block
student familiar al block diagram/
can name with the schematic/ diagram/ code and
Demonstratio the lab block code, and successfull
n hardware environme diagram/ have y executed
or nt (Trainer/ code/ successfull the lab
simulation software/ model on y executed objective in
platform, IDE), but the the Realtime or
but unable cannot protoboard program/ in a
to implement / trainer/ run circuit simulation
implemen on the simulation on environmen
t anything platform software. software t and
practically practically platform produced
or on the or on the the desired
software software results
Category Ungrade Very Poor Fair Good Excellent
d Poor
Percentage [0] [1-20] [21-40] [41-60] [61-80] [81-100]
Marks 0.0 0.1 0.2 0.3 0.4 0.5

Date Total Instructor’s Signature


Marks

Report Plagiarize Requirement Observation Appropriate Correctly


not d content s are listed s are computation drawn
submitte presented and recorded s or conclusio
d or experimental along with numerical n with
Laborator incomplet procedure is detailed analysis is exact
y e presented procedure performed results
Reports submissio and
n complete
report in
all
respects
Category Ungrade Very Poor Fair Good Excellent
d Poor
Percentag [0] [1-20] [21-40] [41-60] [61-80] [81-100]
e
AB LAB MANUAL SOFTWARE DESIGN AND ARCHITECTURE

Marks 0.0 0.1 0.2 0.3 0.4 0.5

Date Total Instructor’s Signature


Marks

You might also like