```© Kristen Nygaard, 2001
Where do programming languages come from?
”Dad, where do the programming languages come from?”
”They come from God, my boy”
”How do they come down to us, Dad?”
”God has created something wonderful called ”inspiration”, and uses that
to bring a language into the minds of some nice and bright people called
”language designers”. They write it down so that we may read it and learn
it.”
”Don’t trouble your brain with such difficult questions. He always has a
deeper meaning with what he does. Read the language manual and learn
it by heart!”
Where do programming languages come from?
Relations between specified quantities,
valid within specified domains
x=a
x = a+b
Rules for transformation
into other valid relations exist, as:
x = x + a implies 0 = a
Description of sequences of events
(state transitions) in processes:
x = x + a does not imply a = 0
x + a => x
Mathematics
In the 1950s it was natural to try to make
programs look like mathematics
(Fortran means Formula Translation)
Mathematics:
Fortran:
y=x,
y = F(x)
y=x,
y = F(x)
Algol and Simula used a different operator:
y := x
y := F(x)
BETA emphasises that programs should describe
processes, not relations:
x => y ,
x => F => y
Mathematics:
y = Fn( F(n-1)(... F2( F1( x ) ).. ).).).).).).)
BETA:
(a,b) => T12 => T23 => ... => T(n-1)n => (x,y,z)
Notation: Mathematics, BETA (98-08-11)
The pedagogics of OO
In pedagogics, a well-known principle is
that the basic concepts should be taught first.
More difficult and composite concepts should
come later, after the basic ones
are understood and mastered.
Object-oriented programming is intended to
comprehend and organise complexity.
Its basic concepts are objects, classes, inheritance,
with objects having attributes, virtuals,
and possibly action sequences (threads) that
may run concurrently.
Teaching object-oriented programming thus
must begin with exposing students to
complex situation that only may be mastered
by understanding and using these concepts.
The pedagogy
The Restaurant, main picture
?
?
The Restaurant: Waiter!/1
?
”Waiter!” …
?
”Waiter!!”...
”Waiter!!!”
”Sorry. Not my table.”
Restaurant:Waiter!/2
How will these people describe
their evening
at Restaurant Objecta?
Alternatives:
Brâne Cantenac. Two bottles
of excellent Hermitage more than made
up for it.”
”Laura is an extraordinarily
intelligent woman. You can read it in her
eyes while she listens to you.”
Object-oriented programming is not
wines, women, men or gastronomy.
The Restaurant: Waiter!/3
F.A.Q:
Object-oriented programming
is not suited to discussions about
poetry, wines,
women or gastronomy. OK.
Q: But what is OO then suited to
describe?
A: Systems.
Q: What is a system?
A: A system is something that you
have decided to regard as a
system.
Q: What does it imply to regard
something as a system?
A: You regard it as a whole,
consisting of components, each
component has pro-perties and
may interact with other
components.
A restaurant owner, a head-waiter, an
architect, an infor-mation system
designer will often regard something as
a system.
The Restaurant: Waiter!/4
?
”Waiter!” …
?
”Waiter!!”...
”Waiter!!!”
”Sorry. Not my table.”
Restaurant:Waiter!/2
”Waiter!” …
”Waiter!!”
”Sorry. Not my table.”
What is ”a table”?
What is a table?
Who will be permitted to enter Restaurant Objecta?
J. P. Morgan IV’s
visit at
Restaurant OBJECTA
J. P. Morgan IV arrives every
day (except weekends) at 17:00,
and leaves 18:00. He has Table 2
reserved, and Peterson, his
He will drink one glass (after a
smart deal: two glasses) of his
special Armagnac 1942, drink
Colombian coffee and smoke a
(Cuban, don’t mention it) cigar.
He is known for always carrying
at least \$ 1000 and a gun.
J. P. Morgan IV’s visit at Objecta
James Smith’s visit
at Restaurant Objecta
James Smith was hilariously
happy when the wonderful
Venus Jones accepted his
dinner invitation
He had \$ 117.35 to spend.
When the (perhaps) naive
she exclaimed: ”They say
that Russian caviar is fantastic with
champagne!”
James Smith did not have
the guts to say ”no”.
Now their waiter, Aku Aku
from Easter Island, waits:
the accumulated bill is
\$ 147.50.
if funds<bill then negotiate
else pay and leave
James Smith’s visit at Objecta
Attributes
Objects are individual identified components having substance
(material existence in our environment, on the substrate of our brain,
on paper, in the memory of a computer).Properties of objects are
called attributes.
A reference is an attribute that indicates some object and its current
state is called its referent.
A quantity is attribute that may be observed and measured, the result
being mapped upon a value set. The current state is called its value.
An action part is an attribute specifying a sequence of transitions to
be carried out by the object, and the current state is called its
ongoing transition.
A pattern attribute is is an attribute
prescribing the common structure for a category of objects. The
collection of an object’s pattern attributes is called its repertoire.
Basic qualities of processes
Substance
Guests, waiters, gatekeepers, tables, chairs,
State
References: My table, My waiter, successor (in queue)
Quantities: Available money, food names, prices, smoker, finished
OBS!Action part: object begin ...
... end object;
Pattern attributes: Order
Transition
Seating, ordering, serving, eating,
paying, negotiating
Structure
(permanent properties of the process)
Basic qualities of processes
Basic qualities of processes
Substance
Guests, waiters, gatekeepers, tables, chairs,
State
Available money, accum. amounts on bills,
guest names, food names, prices, table numbers,
reserved, smoker, finished,
no. of guests,
Transition
Seating, ordering, serving, eating,
paying, negotiating
Structure
Basic qualities of processes
The queue inside,
as gatekeeper
The queue outside,
with the doorman
as gatekeeper
The gatekeepers
J. P. Morgan IV’s visit at Restaurant OBJECTA
Structure
Substance
State
Transition
GUEST 1: object begin
text name (J. P. Morgan IV);
amount funds (\$ 1000.00), accum bill (\$ 147,50);
Boolean smoker (true), finished (false),
reserved table (true)
ref(table) my table (TABLE 2);
ref(waiter) my waiter (PETERSON);
procedure order begin .... end;
if not reserved then begin enter(outside queue); wait end;
enter(inside queue); wait; sit down at my table;
attract ( my waiter); get menu; order drinks;
wait(consider smart deal); drink; attract (my waiter);
while not finished do
begin order food; order drinks; wait (consider smart deal);
eat and drink; if smoker then smoke;
attract (my waiter) end;
ask for check; wait (consider smart deal);
if accum bill ≤ funds then pay else negotiate;
leave end object;
Description of: J. P. Morgan IV/1(2000-05-25)
James Morgan IV’s visit at Restaurant OBJECTA
Colour code: Structure, Substance, State,
GUEST 1: object begin
text name (James Morgan IV);
amount funds (\$ 1000.00), accum bill (\$ 147,50);
Boolean smoker (true), finished (false),
reserved table (true)
ref(table) my table (TABLE 2);
ref(waiter) my waiter (PETERSON);
procedure order begin .... end;
if not reserved then begin enter(outside queue); wait end;
enter(inside queue); wait; sit down at my table;
attract (my waiter); get menu; order drinks;
wait(consider smart deal); drink; attract (my waiter);
while not finished do
begin order food; order drinks; wait (consider smart deal);
eat and drink; if smoker then smoke;
attract (my waiter) end;
ask for check; wait (consider smart deal);
if accum bill ≤ funds then pay else negotiate;
leave end object;
Description of: J. P, Morgan IV/2(2000-05-25)
James Smith’s visit at Restaurant OBJECTA
Structure
Substance
State
Transition
GUEST 9: object begin
text name (JAMES SMITH);
amount funds (\$ 113.35), accum bill (\$ 147,50);
Boolean smoker (false), finished (false),
reserved table (false)
ref(table) my table (TABLE 6);
ref(waiter) my waiter (AKUAKU);
procedure order begin .... end;
if not reserved then begin enter(outside queue); wait end;
enter(inside queue); wait; sit down at my table;
attract ( my waiter); get menu; order drinks;
wait (admire Venus Jones); drink; attract (my waiter);
while not finished do
begin order food; order drinks; wait (admire Venus Jones);
eat and drink; if smoker then smoke;
attract (my waiter) end;
if accum bill ≤ funds then pay else negotiate;
leave end object;
Description
Guest: Jamesof:Smith
James(2000-05-25)
Smith/1(2000-05-25)
Guests’ visit at Restaurant OBJECTA
class guest begin
text name;
amount funds, accum bill;
Boolean smoker, finished, reserved table;
ref(table) my table;
ref(waiter) my waiter;
procedure order begin .... end;
if not reserved then begin enter(outside queue); wait end;
enter(inside queue); wait; sit down at my table;
attract ( my waiter); get menu; order drinks;
wait; drink; attract (my waiter);
while not finished do
begin order food; order drinks; wait;
eat and drink; if smoker then smoke;
attract (my waiter) end;
if accum bill ≤ funds then pay else negotiate;
leave end class;
new guest (J. P. MORGAN IV, 1000.00, 0,
true, false, true, none, none);
new guest (JAMES SMITH, 113.35, 0,
false, false, false, none, none);
Guests at Restaurant ”OBJECTA” (2000-05-25)
Cashier in Restaurant ”OBJECTA” (2000-05-25)
The hub of the money streams.
Hopefully, the cash register model
only reflect that the artist was in a
nostalgic mood. Or that it is one of
the modern gimmicks with a computer inside.
Cashier” (2000-05-25)
Guests (ships)
waiting
outside
restaurant
(harbour)
(harbour
captain)
Waiter
(crane)
Guest (ship)
being tabled
(berthed)
Waiter
(crane)
Waiter
(crane)
Waiter
(crane)
Guests (ships) at tables (berths)
Kitchen
(warehouses delivering goods)
Warehouses receiving goods
Harbour as restaurant
Basic qualities of processes
Substance
Guests, waiters, tables, food - Ships, berths, cranes Clerks, customers, waiting lines, accounts Records, documents, files
State
No. of guests, prices, accum. amounts on bills Largest free berth length, crane speed, crane max. load Client waiting time, clerk’s average transaction time Document’s arrival date, name of sender, department code
Transition
Structure
Basic qualities of processes
Attributes of objects
(themselves having substance)
Substance attributes
Guests:
Successor guests in waiting line,
Waiters:
Table units, orders, cashier,chef
Ships:
Berth, crane, containers
Documents:
State attributes
Guests:
Available money, accumulated bill,
smoker/non-smoker, finished
Waiters:
No. of tables, busy/available, accum. tips
Ships:
Documents:
Arrival date, security level, ref.no.
Transition attributes
Guests:
Entering outside queue, waiting, waiting
inside for table, getting attention and menu,
ordering, waiting, eating, paying, leaving
Waiters:
Order cycle: Getting orders- informing kitchen
- delivering food, presenting bill, collecting
Ships:
Documents:
Creation, sending, receiving, filing, updating
Attributes of objects
Reference: Substance state
Scope
Specifier +
Block struct.
Structure
Designation
State
Category:
Reference
Name,
Identifier
Referent
Ref (bill)
MyBill
Reference: Substance state - 1 (2000-05-22)
Bill
Reference: Substance state
Scope
Specifier +
Block struct.
internal
Structure
Designation
State
Category:
Reference
Name,
Identifier
Referent
Ref (bill)
MyBill
Reference: Substance state - 2 (2000-05-22)
Bill
Quantity: Measured value state
Scope
Specifier +
Block struct.
Structure
Designation
State
Category:
Type
Name,
Identifier
Value
Integer
Age
34
Quantities/Measured state(2000-05-25)
Pattern: Structure state
Scope
Specifier +
Block struct.
internal
Structure
Category:
Pattern
Class (or Type
or Procedure)
Designation
Name,
Identifier
P
Pattern: Structure state (2000-05-22)
State
Structure
Description
begin …
…. end
Roaming
Cattle Herds
mobile milking machines
Cattle
Surveillance
Milking Machine
Milking Machine
Structural similarity between very diverse systems:
Intercepting cattle herds by mobile milking machines
(Introducing SIMULA 67 to UNIVAC’s civilian and military simulation groups in 1967)
Intercepting cattle herds (98-08-09)
```