SlideShare a Scribd company logo
21CSC101T OBJECT ORIENTED DESIGN
AND PROGRAMMING
Dr.M.Sivakumar
AP/NWC
SRMIST
Course Outcomes (CO)
At the end of this course, learners will be able to:
• CO-1: Create programs using object-oriented approach and
design methodologies
• CO-2: Construct programs using method overloading and
operator overloading
• CO-3: Create programs using inline, friend and virtual
functions, construct programs using standard templates
• CO-4: Construct programs using exceptional handling and
collections
• CO-5: Create Models of the system using UML Diagrams
Unit-2 - Methods and Polymorphism
• Constructors - Types of constructors
• Static constructor and Copy constructor
• Destructor
• Polymorphism: Constructor overloading
• Method Overloading
• Operator Overloading
• UML Interaction Diagrams
• Sequence Diagram
• Collaboration Diagram - Example Diagram
Constructors
• A constructor is a special member
function of a class that is
automatically called when an
instance of the class is created.
Constructors
• It is very common for some part of an object to require initialization before
it can be used.
• Suppose you are working on 100's of objects and the default value of a
particular data member is needed to be zero.
• Initializing all objects manually will be very tedious job.
• Instead, you can define a constructor function which initializes that data
member to zero.
• Then all you have to do is declare object and constructor will initialize
object automatically
Constructors
• While defining a constructor you must remember that the name of
constructor will be same as the name of the class
• constructors will never have a return type
• Syntax:
class MyClass
{
public:
// Constructor declaration
MyClass()
{
// Constructor body
// Initialization code goes here
}
};
Constructors
• Constructors are automatically called when an object of the class is
created.
• For example:
int main()
{
MyClass obj1; // Calls the default constructor
MyClass obj2(10); // Calls the parameterized constructor
return 0;
}
Defining Constructors
• Inside the class
• Outside the class
Defining Constructors – Inside the class
#include<iostream>
using namespace std;
class student
{
int rno;
char name[50];
double fee;
public:
student()// Explicit Default constructor
{
cout<<"Enter the RollNo:";
cin>>rno;
cout<<"Enter the Name:";
cin>>name;
cout<<"Enter the Fee:";
cin>>fee;
}
void display()
{
cout<<endl<<rno<<"t"<<name<<"t"<<fee;
}
};
int main()
{
student s;
s.display();
return 0;
}
Defining Constructors – Outside the class
// defining the constructor outside the class
#include <iostream>
using namespace std;
class student
{
int rno;
char name[50];
double fee;
public:
student();
void display()
{
cout << endl << rno << "t" << name << "t" << fee;
}
};
student::student()
{
cout << "Enter the RollNo:";
cin >> rno;
cout << "Enter the Name:";
cin >> name;
cout << "Enter the Fee:";
cin >> fee;
}
int main()
{
student s;
s.display();
return 0;
}
Types of constructors
• Default Constructor
• Parameterized Constructor
• Copy Constructor
Default Constructor
• As soon as the object is created the constructor is called
which initializes its data members.
• A default constructor is so important for initialization of
object members, that even if we do not define a
constructor explicitly, the compiler will provide a default
constructor implicitly.
Parameterized Constructor
• These are the constructors with parameter.
• Using this Constructor you can provide different values
to data members of different objects, by passing the
appropriate values as argument.
Copy Constructor
• These are special type of Constructors which takes an
object as argument
• Is used to copy values of data members of one object
into other object.
• It is usually of the form X (X&), where X is the class
name.
• The compiler provides a default Copy Constructor to all
the classes.
Copy Constructor
• As it is used to create an object, hence it is called a
constructor. And, it creates a new object, which is exact
copy of the existing copy, hence it is called copy
constructor.
Copy Constructor
#include<iostream>
#include<string>
using namespace std;
class student
{
int rno;
string name;
double fee;
public:
student(int,string,double);
student(student &t) //copy constructor
{
rno=t.rno;
name=t.name;
fee=t.fee;
}
void display();
};
int main()
{
student s(1001,"Manjeet",10000);
s.display();
student manjeet(s); //copy constructor called
manjeet.display();
return 0;
}
student::student(int no,string n,double f){
rno=no;
name=n;
fee=f;
}
void student::display(){
cout<<endl<<rno<<"t"<<name<<"t"<<fee;
}
Destructor
• A destructor works opposite to constructor
• it destructs the objects of classes.
• It can be defined only once in a class.
• Like constructors, it is invoked automatically.
• A destructor is defined like constructor.
• It must have same name as class.
• But it is prefixed with a tilde sign (~).
Destructor
#include <iostream>
using namespace std;
class Employee
{
public:
Employee()
{
cout<<"Constructor Invoked"<<endl;
}
~Employee()
{
cout<<"Destructor Invoked"<<endl;
}
};
int main(void)
{
Employee e1; //creating an object of Employee
Employee e2; //creating an object of Employee
return 0;
}
Output:
Constructor Invoked
Constructor Invoked
Destructor Invoked
Destructor Invoked
Polymorphism
Polymorphism: Constructor overloading
• When we overload a constructor more than a purpose it
is called constructor overloading.
Method Overloading
#include <iostream>
using namespace std;
class Cal
{
public:
int add(int a,int b)
{
return a + b;
}
int add(int a, int b, int c)
{
return a + b + c;
}
};
int main(void)
{
Cal C;
//class object declaration.
cout<<C.add(10, 20)<<endl;
cout<<C.add(12, 20, 23);
return 0;
}
Operator Overloading
• the ability to provide the operators with a special
meaning for a data type
• a compile-time polymorphism
• we can overload an operator ‘+’ in a class like String so
that we can concatenate two strings by just using +
Operators that can be Overloaded in C++
• Unary operators
• Binary operators
• Special operators ( [ ], (), etc)
Operators that can be Overloaded in C++
Operators that can be overloaded Examples
Binary Arithmetic +, -, *, /, %
Unary Arithmetic +, -, ++, —
Assignment =, +=,*=, /=,-=, %=
Bitwise & , | , << , >> , ~ , ^
De-referencing (->)
Dynamic memory allocation,
De-allocation
New, delete
Subscript [ ]
Function call ()
Logical &, | |, !
Relational >, < , = =, <=, >=
Operator that cannot be overloaded
• Scope operator (::)
• Sizeof
• member selector(.)
• member pointer selector(*)
• ternary operator(?:)
Rules for Operator Overloading
• Existing operators can only be overloaded, but the new operators
cannot be overloaded.
• The overloaded operator contains atleast one operand of the user-
defined data type.
• We cannot use friend function to overload certain operators.
However, the member function can be used to overload those
operators.
• When unary operators are overloaded through a member function
take no explicit arguments, but, if they are overloaded by a friend
function, takes one argument.
• When binary operators are overloaded through a member function
takes one explicit argument, and if they are overloaded through a
friend function takes two explicit arguments.
Syntax of Operator Overloading
return_type class_name : : operator op(argument_list)
{
// body of the function.
}
return type - the type of value returned by the function
class_name - the name of the class
operator op - an operator function where op is the operator being overloaded,
and the operator is the keyword
Overloading
Unary operator
#include <iostream>
using namespace std;
class OperOverLoad
{
private:
int num;
public:
OperOverLoad(int n)
{
num=n;
}
void operator ++()
{
num = num+2;
}
void display()
{
cout<<"The Count is: "<<num;
}
};
int main()
{
OperOverLoad obj(7);
++obj; // calling of a function "void operator ++()"
obj.display();
return 0;
}
Overloading
Binary operator
#include <iostream>
using namespace std;
class Complex
{
private:
int real, imag;
public:
Complex(int r = 0, int i = 0) // with default arguments
{
real = r;
imag = i;
}
Complex operator+(Complex obj)
{
Complex res;
res.real = real + obj.real;
res.imag = imag + obj.imag;
return res;
}
void print() { cout << real << " + i" << imag << 'n'; }
};
int main()
{
Complex c1(10, 5), c2(2, 4);
Complex c3 = c1 + c2;
c3.print();
}
Output:
12 + i9
UML Interaction Diagrams
• Interaction diagrams are used to observe the dynamic
behavior of a system.
• Interaction diagram visualizes the communication and
sequence of message passing in the system.
• Interaction diagram represents the structural aspects of
various objects in the system.
• Interaction diagram represents the ordered sequence of
interactions within a system.
• Interaction diagram provides the means of visualizing the
real time data via UML.
UML Interaction Diagrams
• This interactive behavior is represented in UML by two
diagrams known as
– Sequence diagram
– Collaboration diagram.
• Sequence diagram emphasizes on time sequence of
messages from one object to another.
• Collaboration diagram emphasizes on the structural
organization of the objects that send and receive
messages.
How to Draw an Interaction Diagram?
• Purpose of interaction diagrams is to capture the dynamic aspect of a
system.
• So to capture the dynamic aspect, we need to understand what a dynamic
aspect is and how it is visualized.
• Dynamic aspect can be defined as the snapshot of the running system at a
particular moment.
• Following things are to be identified clearly before drawing the interaction
diagram
– Objects taking part in the interaction.
– Message flows among the objects.
– The sequence in which the messages are flowing.
– Object organization.
Sequence Diagram
• A sequence diagram is a type of interaction
diagram because it describes how—and in what order—
a group of objects works together.
• A sequence diagram simply depicts interaction between
objects in a sequential order
i.e. the order in which these interactions take place.
• The sequence diagram captures the time sequence of
the message flow from one object to another
Sequence Diagram for course registration
Sequence
Diagram for
ATM
Sequence
Diagram for
Online Shopping
Collaboration Diagram
• The collaboration diagram describes the organization of
objects in a system taking part in the message flow
• Communication diagrams also illustrate interactions
between objects or components, but they focus more
on the relationships and interactions between objects
rather than the sequence of messages.
Collaboration
diagram for ATM
Collaboration
diagram for
Online
Shopping
Learning Resources
• Grady Booch, Robert A. Maksimchuk, Michael W. Engle,
Object-Oriented Analysis and Design with Applications, 3rd
ed., Addison-Wesley, May 2007
• Reema Thareja, Object Oriented Programming with C++, 1st
ed., Oxford University Press, 2015
• Sourav Sahay, Object Oriented Programming with C++, 2nd
ed., Oxford University Press, 2017
• Robert Lafore, Object-Oriented Programming in C++, 4th
ed., SAMS Publishing, 2008
• Ali Bahrami, Object Oriented Systems Development”,
McGraw Hill, 2004

More Related Content

PPTX
21CSC101T best ppt ever OODP UNIT-2.pptx
PPT
C++ - Constructors,Destructors, Operator overloading and Type conversion
PDF
A COMPLETE FILE FOR C++
PDF
Unit 2 Methods and Polymorphism-Object oriented programming
PPT
Bca 2nd sem u-2 classes & objects
PDF
22 scheme OOPs with C++ BCS306B_module2.pdfmodule2.pdf
PPT
Mca 2nd sem u-2 classes & objects
21CSC101T best ppt ever OODP UNIT-2.pptx
C++ - Constructors,Destructors, Operator overloading and Type conversion
A COMPLETE FILE FOR C++
Unit 2 Methods and Polymorphism-Object oriented programming
Bca 2nd sem u-2 classes & objects
22 scheme OOPs with C++ BCS306B_module2.pdfmodule2.pdf
Mca 2nd sem u-2 classes & objects

Similar to Object Oriented Design and Programming Unit-02 (20)

PPT
Unit ii
PDF
Unit3_OOP-converted.pdf
PPT
Friend this-new&delete
PDF
Ch-4-Operator Overloading.pdf
PPTX
Class and object
PPTX
Chapter 2 OOP using C++ (Introduction).pptx
PPTX
Constructor in c++
PPT
14 operator overloading
PPTX
OBJECT ORIENTED PROGRAMING IN C++
PPT
Object Oriented Technologies
PDF
Polymorphism and Type Conversion.pdf pot
PDF
Lec 8.pdf a
PPT
Oop Constructor Destructors Constructor Overloading lecture 2
PPTX
CSC2161Programming_in_Cpp_Lecture4-OOP Classes and Objects[1].pptx
PPTX
C++ process new
PPTX
OOC MODULE1.pptx
PPTX
c++.pptxwjwjsijsnsksomammaoansnksooskskk
PPTX
C++ training
PDF
Operator overloading
Unit ii
Unit3_OOP-converted.pdf
Friend this-new&delete
Ch-4-Operator Overloading.pdf
Class and object
Chapter 2 OOP using C++ (Introduction).pptx
Constructor in c++
14 operator overloading
OBJECT ORIENTED PROGRAMING IN C++
Object Oriented Technologies
Polymorphism and Type Conversion.pdf pot
Lec 8.pdf a
Oop Constructor Destructors Constructor Overloading lecture 2
CSC2161Programming_in_Cpp_Lecture4-OOP Classes and Objects[1].pptx
C++ process new
OOC MODULE1.pptx
c++.pptxwjwjsijsnsksomammaoansnksooskskk
C++ training
Operator overloading
Ad

More from Sivakumar M (12)

PPTX
Introduction to Operating Systems and its basics
PPTX
Operating Systems Process Management.pptx
PPTX
Operating Systems Protection and Security
PPTX
Operating Systems CPU Scheduling and its Algorithms
PPTX
18CSC311J WEB DESIGN AND DEVELOPMENT UNIT-4
PPTX
18CSC311J WEB DESIGN AND DEVELOPMENT UNIT-2
PPTX
18CSC311J WEB DESIGN AND DEVELPMENT UNIT-1
PPTX
18CSC311J Web Design and Development UNIT-3
PPTX
Object Oriented Design and Programming Unit-05
PPTX
Object Oriented Design and Programming Unit-04
PPTX
Object Oriented Design and Programming Unit-03
PPTX
Object Oriented Design and Programming Unit-01
Introduction to Operating Systems and its basics
Operating Systems Process Management.pptx
Operating Systems Protection and Security
Operating Systems CPU Scheduling and its Algorithms
18CSC311J WEB DESIGN AND DEVELOPMENT UNIT-4
18CSC311J WEB DESIGN AND DEVELOPMENT UNIT-2
18CSC311J WEB DESIGN AND DEVELPMENT UNIT-1
18CSC311J Web Design and Development UNIT-3
Object Oriented Design and Programming Unit-05
Object Oriented Design and Programming Unit-04
Object Oriented Design and Programming Unit-03
Object Oriented Design and Programming Unit-01
Ad

Recently uploaded (20)

PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
Internet of Things (IOT) - A guide to understanding
PPT
Mechanical Engineering MATERIALS Selection
PPTX
additive manufacturing of ss316l using mig welding
PDF
composite construction of structures.pdf
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPT
Project quality management in manufacturing
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
web development for engineering and engineering
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Automation-in-Manufacturing-Chapter-Introduction.pdf
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Internet of Things (IOT) - A guide to understanding
Mechanical Engineering MATERIALS Selection
additive manufacturing of ss316l using mig welding
composite construction of structures.pdf
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
CH1 Production IntroductoryConcepts.pptx
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Project quality management in manufacturing
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Model Code of Practice - Construction Work - 21102022 .pdf
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
web development for engineering and engineering
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Foundation to blockchain - A guide to Blockchain Tech
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf

Object Oriented Design and Programming Unit-02

  • 1. 21CSC101T OBJECT ORIENTED DESIGN AND PROGRAMMING Dr.M.Sivakumar AP/NWC SRMIST
  • 2. Course Outcomes (CO) At the end of this course, learners will be able to: • CO-1: Create programs using object-oriented approach and design methodologies • CO-2: Construct programs using method overloading and operator overloading • CO-3: Create programs using inline, friend and virtual functions, construct programs using standard templates • CO-4: Construct programs using exceptional handling and collections • CO-5: Create Models of the system using UML Diagrams
  • 3. Unit-2 - Methods and Polymorphism • Constructors - Types of constructors • Static constructor and Copy constructor • Destructor • Polymorphism: Constructor overloading • Method Overloading • Operator Overloading • UML Interaction Diagrams • Sequence Diagram • Collaboration Diagram - Example Diagram
  • 4. Constructors • A constructor is a special member function of a class that is automatically called when an instance of the class is created.
  • 5. Constructors • It is very common for some part of an object to require initialization before it can be used. • Suppose you are working on 100's of objects and the default value of a particular data member is needed to be zero. • Initializing all objects manually will be very tedious job. • Instead, you can define a constructor function which initializes that data member to zero. • Then all you have to do is declare object and constructor will initialize object automatically
  • 6. Constructors • While defining a constructor you must remember that the name of constructor will be same as the name of the class • constructors will never have a return type • Syntax: class MyClass { public: // Constructor declaration MyClass() { // Constructor body // Initialization code goes here } };
  • 7. Constructors • Constructors are automatically called when an object of the class is created. • For example: int main() { MyClass obj1; // Calls the default constructor MyClass obj2(10); // Calls the parameterized constructor return 0; }
  • 8. Defining Constructors • Inside the class • Outside the class
  • 9. Defining Constructors – Inside the class #include<iostream> using namespace std; class student { int rno; char name[50]; double fee; public: student()// Explicit Default constructor { cout<<"Enter the RollNo:"; cin>>rno; cout<<"Enter the Name:"; cin>>name; cout<<"Enter the Fee:"; cin>>fee; } void display() { cout<<endl<<rno<<"t"<<name<<"t"<<fee; } }; int main() { student s; s.display(); return 0; }
  • 10. Defining Constructors – Outside the class // defining the constructor outside the class #include <iostream> using namespace std; class student { int rno; char name[50]; double fee; public: student(); void display() { cout << endl << rno << "t" << name << "t" << fee; } }; student::student() { cout << "Enter the RollNo:"; cin >> rno; cout << "Enter the Name:"; cin >> name; cout << "Enter the Fee:"; cin >> fee; } int main() { student s; s.display(); return 0; }
  • 11. Types of constructors • Default Constructor • Parameterized Constructor • Copy Constructor
  • 12. Default Constructor • As soon as the object is created the constructor is called which initializes its data members. • A default constructor is so important for initialization of object members, that even if we do not define a constructor explicitly, the compiler will provide a default constructor implicitly.
  • 13. Parameterized Constructor • These are the constructors with parameter. • Using this Constructor you can provide different values to data members of different objects, by passing the appropriate values as argument.
  • 14. Copy Constructor • These are special type of Constructors which takes an object as argument • Is used to copy values of data members of one object into other object. • It is usually of the form X (X&), where X is the class name. • The compiler provides a default Copy Constructor to all the classes.
  • 15. Copy Constructor • As it is used to create an object, hence it is called a constructor. And, it creates a new object, which is exact copy of the existing copy, hence it is called copy constructor.
  • 16. Copy Constructor #include<iostream> #include<string> using namespace std; class student { int rno; string name; double fee; public: student(int,string,double); student(student &t) //copy constructor { rno=t.rno; name=t.name; fee=t.fee; } void display(); }; int main() { student s(1001,"Manjeet",10000); s.display(); student manjeet(s); //copy constructor called manjeet.display(); return 0; } student::student(int no,string n,double f){ rno=no; name=n; fee=f; } void student::display(){ cout<<endl<<rno<<"t"<<name<<"t"<<fee; }
  • 17. Destructor • A destructor works opposite to constructor • it destructs the objects of classes. • It can be defined only once in a class. • Like constructors, it is invoked automatically. • A destructor is defined like constructor. • It must have same name as class. • But it is prefixed with a tilde sign (~).
  • 18. Destructor #include <iostream> using namespace std; class Employee { public: Employee() { cout<<"Constructor Invoked"<<endl; } ~Employee() { cout<<"Destructor Invoked"<<endl; } }; int main(void) { Employee e1; //creating an object of Employee Employee e2; //creating an object of Employee return 0; } Output: Constructor Invoked Constructor Invoked Destructor Invoked Destructor Invoked
  • 20. Polymorphism: Constructor overloading • When we overload a constructor more than a purpose it is called constructor overloading.
  • 21. Method Overloading #include <iostream> using namespace std; class Cal { public: int add(int a,int b) { return a + b; } int add(int a, int b, int c) { return a + b + c; } }; int main(void) { Cal C; //class object declaration. cout<<C.add(10, 20)<<endl; cout<<C.add(12, 20, 23); return 0; }
  • 22. Operator Overloading • the ability to provide the operators with a special meaning for a data type • a compile-time polymorphism • we can overload an operator ‘+’ in a class like String so that we can concatenate two strings by just using +
  • 23. Operators that can be Overloaded in C++ • Unary operators • Binary operators • Special operators ( [ ], (), etc)
  • 24. Operators that can be Overloaded in C++ Operators that can be overloaded Examples Binary Arithmetic +, -, *, /, % Unary Arithmetic +, -, ++, — Assignment =, +=,*=, /=,-=, %= Bitwise & , | , << , >> , ~ , ^ De-referencing (->) Dynamic memory allocation, De-allocation New, delete Subscript [ ] Function call () Logical &, | |, ! Relational >, < , = =, <=, >=
  • 25. Operator that cannot be overloaded • Scope operator (::) • Sizeof • member selector(.) • member pointer selector(*) • ternary operator(?:)
  • 26. Rules for Operator Overloading • Existing operators can only be overloaded, but the new operators cannot be overloaded. • The overloaded operator contains atleast one operand of the user- defined data type. • We cannot use friend function to overload certain operators. However, the member function can be used to overload those operators. • When unary operators are overloaded through a member function take no explicit arguments, but, if they are overloaded by a friend function, takes one argument. • When binary operators are overloaded through a member function takes one explicit argument, and if they are overloaded through a friend function takes two explicit arguments.
  • 27. Syntax of Operator Overloading return_type class_name : : operator op(argument_list) { // body of the function. } return type - the type of value returned by the function class_name - the name of the class operator op - an operator function where op is the operator being overloaded, and the operator is the keyword
  • 28. Overloading Unary operator #include <iostream> using namespace std; class OperOverLoad { private: int num; public: OperOverLoad(int n) { num=n; } void operator ++() { num = num+2; } void display() { cout<<"The Count is: "<<num; } }; int main() { OperOverLoad obj(7); ++obj; // calling of a function "void operator ++()" obj.display(); return 0; }
  • 29. Overloading Binary operator #include <iostream> using namespace std; class Complex { private: int real, imag; public: Complex(int r = 0, int i = 0) // with default arguments { real = r; imag = i; } Complex operator+(Complex obj) { Complex res; res.real = real + obj.real; res.imag = imag + obj.imag; return res; } void print() { cout << real << " + i" << imag << 'n'; } }; int main() { Complex c1(10, 5), c2(2, 4); Complex c3 = c1 + c2; c3.print(); } Output: 12 + i9
  • 30. UML Interaction Diagrams • Interaction diagrams are used to observe the dynamic behavior of a system. • Interaction diagram visualizes the communication and sequence of message passing in the system. • Interaction diagram represents the structural aspects of various objects in the system. • Interaction diagram represents the ordered sequence of interactions within a system. • Interaction diagram provides the means of visualizing the real time data via UML.
  • 31. UML Interaction Diagrams • This interactive behavior is represented in UML by two diagrams known as – Sequence diagram – Collaboration diagram. • Sequence diagram emphasizes on time sequence of messages from one object to another. • Collaboration diagram emphasizes on the structural organization of the objects that send and receive messages.
  • 32. How to Draw an Interaction Diagram? • Purpose of interaction diagrams is to capture the dynamic aspect of a system. • So to capture the dynamic aspect, we need to understand what a dynamic aspect is and how it is visualized. • Dynamic aspect can be defined as the snapshot of the running system at a particular moment. • Following things are to be identified clearly before drawing the interaction diagram – Objects taking part in the interaction. – Message flows among the objects. – The sequence in which the messages are flowing. – Object organization.
  • 33. Sequence Diagram • A sequence diagram is a type of interaction diagram because it describes how—and in what order— a group of objects works together. • A sequence diagram simply depicts interaction between objects in a sequential order i.e. the order in which these interactions take place. • The sequence diagram captures the time sequence of the message flow from one object to another
  • 34. Sequence Diagram for course registration
  • 37. Collaboration Diagram • The collaboration diagram describes the organization of objects in a system taking part in the message flow • Communication diagrams also illustrate interactions between objects or components, but they focus more on the relationships and interactions between objects rather than the sequence of messages.
  • 40. Learning Resources • Grady Booch, Robert A. Maksimchuk, Michael W. Engle, Object-Oriented Analysis and Design with Applications, 3rd ed., Addison-Wesley, May 2007 • Reema Thareja, Object Oriented Programming with C++, 1st ed., Oxford University Press, 2015 • Sourav Sahay, Object Oriented Programming with C++, 2nd ed., Oxford University Press, 2017 • Robert Lafore, Object-Oriented Programming in C++, 4th ed., SAMS Publishing, 2008 • Ali Bahrami, Object Oriented Systems Development”, McGraw Hill, 2004