Object Oriented Programming: Week 1
Object Oriented Programming: Week 1
WEEK 1
ABEER GAUHER
EMAIL: [email protected]
OFFICE: CS BASEMENT 2, OFFICE NUMBER 17
Contents 2
Procedural
For example,
Beginners Allpurpose Symbolic Instruction Code (BASIC) – it was
developed to enable more people to write programs.
C – a general-purpose programming language, initially developed
by Dennis Ritchie between 1969 and 1973 at AT&T Bell Labs.
Describe, step by step, exactly the procedure that should, according
to the particular programmer at least, be followed to solve a specific
problem.
Programming Paradigms 6
Object-oriented
Data and methods to manipulate it are kept as one unit
called an object.
With perfect encapsulation, one of the distinguishing
features of OOP, the only way that another object or user
would be able to access the data is via the object's methods.
Thus, an object's inner workings may be changed without
affecting any code that uses the object.
7
Procedural vs. Object-Oriented 8
Programming
What is a Model? 9
Highway maps
Architectural models
Mechanical models
Example – OO Model 11
Example – OO Model 12
lives-in
Ali House
Objects
Ali drives
House
Interactions
Ali lives in the house
Ali drives the car
Object-Orientation - Advantages 13
An object is
Something tangible (Ali, Car)
Something that can be apprehended intellectually (Time, Date)
An object has
State (attributes)
Well-defined behaviour (operations)
Unique identity
Concept: An object has behaviors 17
State (attributes)
Name
Age
behaviour (operations)
Walks
Eats
Example – Car is a Tangible Object 19
State (attributes)
- Color
- Model
behaviour (operations)
- Accelerate - Start Car
- Change Gear
Example – Date is an Object Apprehended 20
Intellectually
State (attributes)
Year - Day
Month
behaviour (operations)
- Set Year - Set Day
- Set Month
Data Abstraction 21