Lecture 1
Lecture 1
Course
Object Oriented
Programming (OOP)
Instructor
2
Programming Languages
Programming languages allow programmers to code software.
The three major families of languages are:
Machine languages
Assembly languages
High-Level languages
3
Machine Languages
Comprised of 1s and 0s
The “native” language of a computer
Difficult to program – one misplaced 1 or 0 will cause the
program to fail.
Example of code:
1110100010101 111010101110
10111010110100 10100011110111
4
Assembly Languages
Assembly languages are a step towards easier programming.
Assembly languages are comprised of a set of elemental
commands which are tied to a specific processor.
Assembly language code needs to be translated to machine
language before the computer processes it.
Example:
ADD 1001010, 1011010
ADD AX,BX
5
High-Level Languages
High-level languages represent a giant leap towards
easier programming.
The syntax of HL languages is similar to English.
Historically, we divide HL languages into two groups:
Procedural languages
Object-Oriented languages (OOP)
6
Procedural Programming
7
Procedural Languages
Procedural programming is the standard approach used in
early High-Level computer language such as C, Pascal,
FORTRAN & BASIC.
Procedural programming creates a step-by-step program
that guides the application through a sequence of
instructions. Each instruction is executed in order.
Code in procedural languages is executed sequentially,
from top to bottom.
The program starts at the main entry point and follows a
linear path, executing each statement in order.
8
Procedural Languages
Using function
Function & program is divided into modules
Every module has its own data and function
which can be called by other modules.
9
TASK
Find errors in the program?
#include <iostream>
#include <stdio.h>
int main() {
cout << "Hello, World!" <<endl
return 0;
}
What is the output of this program.
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
int x = 5;
int y = x++;
cout << "x: " << x <<endl;
cout << "y: " << y <<endl;
return 0;
}
10
Object-Orientation
11
Object-Orientation
A thinking methodology
Everything is an object.
Any system is composed of objects (a system is also an
object).
The evolution and development of a system is caused by
the interactions of the objects inside/outside a system.
12
Everything is an object
A student, a professor
A desk, a chair, a classroom, a building
A university, a city, a country
The world, the universe
A subject such as CS, IS, Math, History, …
13
Systems are composed of objects
An educational system
An economic system
An information system
A computer system
14
Object-Oriented Languages
15
Object-Oriented Languages
18
Object-Oriented Programming
19
Object-Oriented Programming
21
Object-Oriented Programming
Object 2
Object 1
Data Data
Function Function
Object 3
Data
Function
22
Procedural Programming vs OOP
A Real-World Example:
Let's say that you are working for a vehicle parts manufacturer that needs to
update it's online inventory system. Your boss tells you to program two similar
but separate forms for a website, one form that processes information about
cars and one that does the same for trucks.
For cars, we will need to record the following information: Color, Engine Size,
Transmission Type, Number of doors
For trucks, the information will be similar, but slightly different. We need:
Color, Engine Size, Transmission Type, Cab Size, Towing Capacity
23
Procedural Programming vs OOP
Scenario 1
Example: C++, Java, Python etc Example: C, Fortran, Pascal, Basic etc
27
Thank You
Any Questions
28