Programming paradigms
A way of thinking about programming
The programmer's mental model
The structure of the approach
The limitations of the solution
A sequence of actions
width_1 = 12.0
height_1 = 27.2
area_1 = width_1 * height_1
width_2 = 93.2
area_2 = width_2 * height_1
height_2 = 47
area_3 = width_1 * height_2
...
A set of functions, defined and used
def area(width, height):
return width * height
width_1 = 12.0
height_1 = 27.2
width_2 = 93.2
height_2 = 47
area_1 = area(width_1, height_1)
area_2 = area(width_2, height_1)
area_3 = area(width_1, height_2)
But functions are characterized by their inputs
def area(width, height):
return width * height
width_1 = ?
height_1 = ?
width_2 = ?
height_2 = ?
Functions and data are interdependent
Numeric data, numeric functions
Alphabetic data, alphabetic functions
Image data, image functions
Geometric data, geometric functions
and so forth ...
A new paradigm
Since the functions and data are interdependent, combine them.
This combination is called an object.
Programming with objects is called object-oriented programming.
Object-oriented programming: categories
Abstract description of a thing
A "car"
Concrete example of a thing
My 1988 Honda civic with a banged-up side
Object-oriented programming: qualities
Abstract properties of a thing
Make
Model
License plate number
Color
Concrete properties of a thing
Honda
Civic
CA 2JPM905
Brownish
Hey, wait, my car died!
Abstract properties of a thing
Make
Model
License plate number
Color
Concrete properties of a thing
Toyota
Scion xA
An empty value
Weird sparkly gray
Newly discovered properties
Target demographic
Object-oriented programming: processes
Abstract actions done by or to a thing
Start
Brake
Steer
Refuel
Concrete actions done by or to a "car"
Turn key in ignition
Push brake pedal
Turn steering wheel right or left
Open gas tank, insert nozzle, turn on pump
Object-oriented programming: processes
Abstract actions done by or to a thing
Start
Brake
Steer
Refuel
Concrete actions done by or to a "sailboat"
Untie ropes from dock, push off
Loosen the mainsail, drop anchor
Turn rudder right or left
Hope for wind...
Object-oriented inheritance
Shared qualities can be defined as an object
A class to represent "vehicle-ness"
Position
Heading
Speed
A "car" is a "vehicle" specific to land
Generic vehicle-ness + specific car-ness
A "sailboat" is a "vehicle" specific to water
Generic vehicle-ness + specific sailboat-ness
Object-oriented terminology
An abstract object description is a class
A single concrete object is an instance.
An instance stores its data in instance variables
The class functions are called methods.
... sometimes ...
Object-oriented terminology
So we'll say:
"We make an instance of a class."
"It has data." (instance variables)
"It has functions." (methods)
Object-oriented programming and images
What's in the set of image object properties?
Pixel width
Pixel height
Number of channels
grey values, RGB, RGBA (RGB with matte)
What are the functions of the image object?
Read an image file
Write an image file
Get a pixel value
Set a pixel value
Programming as problem modeling
Choose objects that make sense for the problem to be solved.
(Sounds like engineering...)
Programming as artistic modeling
Choose objects that enhance your ability to explore artistic possibilities.
(These objects may having nothing to do with engineering...)

Objects?