0% found this document useful (0 votes)
14 views

CSC186 - 2) Basic OO Design Using UML (Part 2)

Uploaded by

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

CSC186 - 2) Basic OO Design Using UML (Part 2)

Uploaded by

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

CSC186

OBJECT ORIENTED
PROGRAMMING
Topic 2:
Basic OO Design using UML
(Part 2)
CLASS DIAGRAM
Classes

◦ A class is a collection of similar (attributes, operations, relationships) objects.

◦ Class is represented as a rectangle in UML.


Classes - Attributes

◦ Each class has attributes.

◦ An attribute is a property.

◦ These attributes are similar for all the objects of the class.
Classes – Attributes (cont…)
◦ Attributes may be represented only with names or along with the type and an initial
value.
Classes - Operations

◦ Class also has behaviors (operations)

◦ An operation is an implementation of service that can be requested from any


object of the class to affect its behavior.

◦ These operations are similar for all the objects of the class.
Classes – Operations
◦ An operation may be represented only with its name or along with the parameters
or with the return type.
Test Yourself 3

◦ From the given University Record System:


1. Identify the objects
2. Define the class with the attributes
Classes identified
◦ List of classes
◦ Student
◦ Academic Staff
◦ Admin
◦ Subject

◦ List the attributes.


Test Yourself 4

◦ Draw the classes for the URS using the UML tool.

Hint: From Test Yourself 3


RELATIONSHIP
Relationships

◦ The classes in the models generally collaborate with each other in a number of
ways.

◦ Most of the classes will have connections with other classes known as
relationships.

◦ Three main relationships:


◦ Dependency
◦ Generalization
◦ Association
Relationships - Example

Dependency

Generalization

Association
1) Dependency

◦ A dependency is a relationship.

◦ Dependency is represented graphically as a dashed directed line.

◦ The dependency is directed towards the thing being used.

◦ One object dependent on the other object. Example: object Event dependent on
object Window. Event cannot occur independently without Window.
1) Dependency – Example
2) Generalization

◦ Generalization is often called as “is-a” relationship.

◦ Generalization is a relationship between a general thing and a specific thing.

◦ Generalization specifies that the object of a child can be used at any place
where the object of the parent is used.
2) Generalization
◦ Generalization is represented as a solid directed line with a large open arrow head
pointing towards the general thing.
3) Association
◦ An association can be specified between two classes or between more classes.

◦ An association is represented graphically as a solid line connecting two things.

◦ Object can exist independently. Example : Subject and Lecturer can exist without
each other.
3) Association - Name

◦ An association can have a name. It specifies the type of relationship between the things it
is connecting.

◦ We can give a direction to the name by providing a direction triangle that point in the
direction you intend to read the name

◦ Person works for certain company.

◦ Or these object can exist independently. Person is self-employed, work at home or


housewife. Company does not need any more person or operated on-line.
3) Association - Role
◦ A class plays a specific role in an association relationship.

◦ The role is represented under the association and close to the class icon.
3) Association - Multiplicity
◦ While modeling, it is important to specify how many objects may be connected
across an association.

◦ That “how many” is known as the multiplicity of the association.


3) Association – Composition
◦ Implies the ownership

◦ It defines a one-way relationship that specifies an 'is-part-of' relationship between


two classes
Association - Aggregation
◦ Such relationship is known as aggregation or also called as “has-a”
relationship.

◦ An aggregation is represented graphically by adorning an association with a


open diamond at the whole end.
Association –
Composition vs Aggregation
Class diagram - Example
Relationship
OBJECT DIAGRAM
Object diagram

◦ An object diagram allows us to model the instances of classes in a class


diagram.

◦ Object diagrams are used to model the static design view of the system.

◦ An object diagram contains:


◦ Objects
◦ Links
Class and Object Diagrams
VISIBILITY
Visibility
◦ The visibility feature of a classifier allows us to specify the accessibility of a
certain classifier feature.

◦ Four access specifiers in UML:

Symbol Name Description


+ Public Accessible by all other classifiers
# Protected Accessible only by the descendents and the classifier itself
~ Package Accessible by all the classifiers with the same package
- Private Accessible only by the classifier in which they are available
Visibility - Example

Student

- sid
- sname
- rollno
# email
# mobno
+ register( )
+ login( )
+ logout( )
Test Yourself 5
◦ Assume you want to develop a program for Loan Application.

“Daniel wants to apply the loan from a bank. He goes to the bank and discuss his
application with the loan agent, Mr. Charles. In order to apply the loan, Daniel
must open the loan account and Mr. Charles assists Daniel to submit the
application.”

1. Identify the actor and the activities (use case).


2. Draw the use case diagram for the situation above.
3. Identify the objects involve.
4. Define the classes and the attributes.
Test Yourself 6
Continue from the Test Yourself 5, answer the following questions.

1. Assume the bank offer two type of loan : Personal Loan and Car Loan.
Identify the objects to define the class and their attributes.

2. Identify the relationship between the loans classes.

3. Identify the relationship between the classes.


Test Yourself 7
◦ Complete your class diagram with the classes, visibilities and relationships
using UML tool.
END.
Thank you.

You might also like