OOSD Unit 1
OOSD Unit 1
& Design
(BCS-054)
Unit -1
What Is an Object?
• Definition: An object is a software bundle of
variables and related methods.
• As the name object-oriented implies, objects are
key to understanding object-oriented
technology.
• You can look around you now and see many
examples of real-world objects: your dog, your
desk, your television set, your bicycle.
• Software objects are modeled after real-world
objects in that they, too, have state and
behavior.
Object-Orientation
Analysis Design Implementation
Investigation of
Logical solution. Code.
the problem.
• Object-oriented analysis.
– Investigation that is object-centric.
• Object-oriented design.
– Solution in terms of interacting software
objects.
• Object-oriented programming.
– Coding in an object-oriented
A Simple Data Model
A Simple Object Model
STUDENT
COURSE
-ID Number
-Name -Subject
0..* -Number
-Grade Point Average has record for>
-Title
+Admit() 0..* -Credit
+Regsiter for Classes()
+Create a Course()
+Withdraw()
+Change Address() +Delete from Course Master()
+Calculate GP A() +Change in Course Master()
+Graduate() 1
TRANSCRIPT COURSE
-Semester
-Division
-Grade
+Add()
+Drop()
+Complete()
+Change Grade()
Object Oriented Modeling
What is UML?
Interface:
⚫ Interface defines a set of operations which specify the
responsibility of a class
Collaboration:
⚫ Collaboration defines interaction between elements.
Structural things
Use case:
⚫ Use case represents a set of actions performed by a
system for a specific goal.
Component:
⚫ Component describes physical part of a system.
Node:
⚫ A node can be defined as a physical element that
exists at run time.
Behavioral things
⚫ It consists of the dynamic parts of UML models.
Interaction:
⚫ It is defined as a behavior that consists of a group of
messages exchanged among elements to accomplish
a specific task.
State machine:
⚫ It is useful when the state of an object in its life cycle
is important. It defines the sequence of states an
object goes through in response to events.
Grouping things
⚫ Grouping things can be defined as a mechanism to
group elements of a UML model together. There is
only one grouping thing available:
Package:
⚫ Package is the only one grouping thing available for
gathering structural and behavioral things.
Annotational things
Note
⚫ It is the only one Annotational thing available.
⚫ A note is used to render comments, constraints etc of
an UML element.
Relationships
⚫ It shows how elements are associated with each other
and this association describes the functionality of an
application.
There are four kinds of relationships available.
Dependency:
⚫ Dependency is a relationship between two things in
which change in one element also affects the other
one.
Association:
⚫ Association is basically a set of links that connects
elements of an UML model. It also describes how
many objects are taking part in that relationship.
Relationships
Generalization:
⚫ Generalization can be defined as a relationship which
connects a specialized element with a generalized
element. It basically describes inheritance relationship
in the world of objects.
Realization:
⚫ Realization can be defined as a relationship in which
two elements are connected. One element describes
some responsibility which is not implemented and the
other one implements them. This relationship exists in
case of interfaces.
Notations
Notations
Types of UML Diagrams
⚫ UML includes the following nine diagrams
⚫ Class diagram
⚫ Object diagram
⚫ Use case diagram
⚫ Sequence diagram
⚫ Collaboration diagram
⚫ Activity diagram
⚫ Statechart diagram
⚫ Deployment diagram
⚫ Component diagram
Structural Diagrams
Name
Account_Name
- Customer_Name
Attributes
- Balance
+addFunds( ) Operations
+withDraw( )
+transfer( )
OO Relationships
⚫ There are two kinds of Relationships
◦ Generalization (parent-child relationship)
◦ Association (student enrolls in course)
⚫ Associations can be further classified as
◦ Aggregation
◦ Composition
OO Relationships: Generalization
Regular Loyalty
Customer Customer
Subtype1 Subtype2
or: Customer
- Generalization expresses a
parent/child relationship among related
classes.
- Used for abstracting details in several Regular Loyalty
layers Customer Customer
OO Relationships: Association
student
1 *
University Person
0..1 *
employer teacher
Role
Multiplicity
Symbol Meaning
1 One and only one Role
0..1 Zero or one “A given university groups many people;
M..N From M to N (natural language) some act as students, others as teachers.
* From zero to any positive integer
A given student belongs to a single
university; a given teacher may or may not
0..* From zero to any positive integer
be working for the university at a particular
1..* From one to any positive integer time.”
Association: Model to Implementation
* 4
Student Course
has enrolls
Class Student {
Course enrolls[4];
}
Class Course {
Student have[];
}
OO Relationships: Composition
Composition: expresses a relationship among instances
Whole Class of related classes. It is a specific kind of Whole-Part
Class W relationship.
Apples Milk