Lecture 1 (Introduction To OOP)
Lecture 1 (Introduction To OOP)
Object Oriented
Programming
LECTURE # 1
Course / Lab Marking 2
Assignment
Lab Tasks
Open Lab
Semester Project
Mid Term
Final Exam
Policies 3
CLO 2 Use an object oriented programming language, and associated class libraries, to
develop object oriented programs. 3 C3
CLO 3 Implement, test, and debug programs using object oriented principles in
conjuncture with an integrated development environment. 4 P2
CLO 4 Create appropriate diagrams and textual descriptions to communicate the static
structure and dynamic behaviour of an object oriented solution. 3 C4
Books 6
Text book
Deitel and Deitel, “C++ How to Program,” 7th Edition, ISBN-10: 0-13-611726-0, Prentice Hall,
2009
Reference Books
Robert Lafore, “Object Oriented Programming with C++,” 4th Edition, ISBN-10: 0-672-32308-
7, Sams, 2002
Goran Svenk, “Object-Oriented Programming Using C++ for Engineering and Technology,” 3rd
Edition, 2003
OFFICE HOURS 7
Office # 01, Faculty Cabin, First Floor, Department of Computer & Software
Engineering,
Day Timings
Tuesday 1230 -1430 hrs
Wednesday 1230 – 1430 hrs
Thursday 1230 – 1430 hrs
8
9
https://medium.com/@chris_38599/programming-is-magic-bd61c089729e
Computer Program 10
Programming Paradigms 11
}
Programming Paradigms 14
Procedural
Object Oriented
Procedural Programming 15
Using function
Function & program is divided into modules
Every module has its own data and function which can be called by other
modules.
Procedural Programming Language 16
Example 17
// functions
};
Void main()
{
complexNumber a;
}
What is Object Oriented Programming 21
Variables objects
Types classes
Design a programmer defined datatype 24
Structures
Classes
Structures and Classes 25
To define a data type having more than one pre-defined data types
Once you create a struct type, you can declare one or more objects of that class
type. For example:
Struct circle{ class circle {
// struct body // class body
}; };
void main() void main()
{ {
circle c; circle c;
} }
Objects ?
An object is an instance of a structure
Objects
Attributes
Professor Smith
Professor Mellon
Professor Jones
Contd. 30
31
Contd.
Informally, an object represents an entity, either physical, conceptual, or
software.
― Physical entity
Truck
Chemical
Process
― Conceptual entity
Linked List
― Software entity
Review 32
ORIENTED LANGUAGES
Procedural Language
Views a program as a series of steps to be carried out
E.g. C, FORTRAN, Pascal
Object Oriented Language
Views a program as a group of objects that have certain properties and can
perform certain functions
E.g. C++, Java, C#
PROCEDURAL VS. OBJECT- 34
ORIENTED LANGUAGES
Problems with Procedural Languages
Cannot cope with very large project sizes
Expensive software errors
Causes of Problems
Unrestricted Access to Data
Global data is allowed
Access to data by multiple functions means many connections between functions
Programs become difficult to understand, modify and maintain
PROCEDURAL VS. OBJECT- 35
ORIENTED LANGUAGES
C++
Most widely used
Largest programmer base
Java
Lacks certain features, e.g. multiple inheritance, pointers, templates
Less powerful than C++ (but more safe, of course)
C#
Emerging
Will be covered later in PLE course
THE OO APPROACH 38
The fundamental idea is to combine into a single unit both data and functions
that operate on the data.
Such a unit is called an “Object”.
An object’s functions are called “member functions” or “methods” in C++
And its data is called “ data members”.
THE OO APPROACH 39
If sales guy needs to know how much has he sold, he does not go into
the finance department and start going through the files.
He asks (letter) from finance section to provide him the details
This allows the data integrity/privacy
CHARACTERISTICS OF OO 42
LANGUAGES
Designing new data types (Classes)
Instantiating the data types (Objects)
Inheritance
Reusability
Polymorphism and overloading
Data Abstraction
Encapsulation
Object-Oriented Programming 43
Advantages:
Reusable
OOP: well designed module could be used on future projects.
Procedural Programming: repeatedly reinvent the wheel.
Maintenance
OOP: modular, easy to maintain, interchanged as units without disassembly of the
modules.
Procedural Programming: not well modularized, change the structure, start from
scratch.
Basic Component of OOP 44