CSC186 - 2) Basic OO Design Using UML (Part 2)
CSC186 - 2) Basic OO Design Using UML (Part 2)
OBJECT ORIENTED
PROGRAMMING
Topic 2:
Basic OO Design using UML
(Part 2)
CLASS DIAGRAM
Classes
◦ 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
◦ 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
◦ Draw the classes for the URS using the UML tool.
◦ 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.
Dependency
Generalization
Association
1) Dependency
◦ A dependency is a relationship.
◦ 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 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.
◦ 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
◦ 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.
◦ Object diagrams are used to model the static design view of the system.
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. Assume the bank offer two type of loan : Personal Loan and Car Loan.
Identify the objects to define the class and their attributes.