LECTURE 29
Object-Oriented Programming
Object Oriented Programming
Classes
&
Objects
E7, Fall 2008, M. Frenklach
1
Procedural Programming
•
The design focuses on steps that must be
executed to achieve a desired state.
•
One typically represents data as individual
variables or fields of a structure and
implement operations as functions that take
the variables as arguments.
•
Programs usually call a sequence of
functions each one of which is passed data
functions, each one of which is passed data,
and then returns modified data. Each
function performs an operation or perhaps
many operations on the data.
2
Object-Oriented Design
defines objects, that:
•
organize (systematize) data
•
define methods (functions)
•
link data and methods
•
protect data
•
hide implementation (complexity)
3
Object-Oriented Design
•
A class describes a set of objects with
common characteristics.
•
Objects are specific instances of a class.
The values contained in an object’s
properties are what make an object
different from other objects of the same
class
class.
•
The functions defined by the class (called
th d )
h
t i
l
t bj
t
methods) are what implement object
behaviors that are common to all objects of
a class (you can add two doubles
regardless of their values).
4
This
preview
has intentionally blurred sections.
Sign up to view the full version.