63
A Unified Approach to Modeling and Programming Ole Lehrmann Madsen The Alexandra Institute & Aarhus University Co-author Birger Møller-Pedersen University of Oslo

A Unified Approach to Modeling and Programming

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: A Unified Approach to Modeling and Programming

A Unified Approach to Modeling and Programming

Ole Lehrmann Madsen The Alexandra Institute & Aarhus University

Co-author Birger Møller-Pedersen University of Oslo

Page 2: A Unified Approach to Modeling and Programming

Models 2010 olm 2

Dahl & Nygaard: ACM Turing Award Winners

“for their role in the invention of object-oriented programming, the most widely used programming

model today.” (ACM press release)

Dahl & Nygaard at the time of Simula’s development

Page 3: A Unified Approach to Modeling and Programming

Models 2010 olm 3

More than 30 years of collaboration

Kristen Nygaard Birger Møller-Pedersen Co-author of accompanying paper

Bent Bruun Kristensen

Page 4: A Unified Approach to Modeling and Programming

Contents

  SIMULA: back to the future   What is a model?   The conceptual framework of OO   Language issues

Models 2010 olm 4

Page 5: A Unified Approach to Modeling and Programming

Models 2010 olm 5

SIMULA: back to the future

Page 6: A Unified Approach to Modeling and Programming

Models 2010 olm 6 6 © Kristen Nygaard, 2000

OBJECT ORIENTATION: PAST, PRESENT, FUTURE

KRISTEN NYGAARD

f(x) = g(x) + λ K(x, y)f(y)dy

The Atom: From Mathematics to Monte Carlo

Page 7: A Unified Approach to Modeling and Programming

Models 2010 olm 7 7 © Kristen Nygaard, 2000

OBJECT ORIENTATION: PAST, PRESENT, FUTURE

KRISTEN NYGAARD

SIMULA I opening sentences (98-08-11)

The SIMULA I language report from 1965 opens with these sentences:

“The two main objects of the SIMULA language are:

To provide a language for a precise and standardised description of a wide class of phenomena, belonging to what we may call

“discrete event systems”.

To provide a programming language for an easy generation of simulation programs for

“discrete event systems”.”

Page 8: A Unified Approach to Modeling and Programming

Models 2010 olm 8 8 © Kristen Nygaard, 2000

OBJECT ORIENTATION: PAST, PRESENT, FUTURE

KRISTEN NYGAARD

The past

Page 9: A Unified Approach to Modeling and Programming

Models 2010 olm 9 9 © Kristen Nygaard, 2000

OBJECT ORIENTATION: PAST, PRESENT, FUTURE

KRISTEN NYGAARD

SIMULA I and SIMULA 67 (98-08-11)

SIMULA I was a simulation programming language

that turned out to become a powerful general programming language.

SIMULA 67

is a general programming language that also is a powerful platform

for other, specialised programming languages, as e.g. simulation languages.

Page 10: A Unified Approach to Modeling and Programming

Models 2010 olm 10 10 © Kristen Nygaard, 2000

OBJECT ORIENTATION: PAST, PRESENT, FUTURE

KRISTEN NYGAARD

Vehicle

Car Truck Bus

Ambulance

Virtual properties

SIMULA 67 was triggered off by the invention of inheritance in January 1967.

Page 11: A Unified Approach to Modeling and Programming

The contributions of Simula .

  Object   Class   Subclass – single inheritance   Virtual procedure (method)   Nested/inner classes/procedures   Action combination

  inner

Models 2010 olm 11

Page 12: A Unified Approach to Modeling and Programming

The contributions of Simula ..

  Active objects  Quasiparrallel systems  Coroutines

  Processes and schedulers  Used for defining process scheduling in

class Simulation   Later extended to concurrency  Necessary to be able to control scheduling

  Concurrency abstractions

Models 2010 olm 12

Page 13: A Unified Approach to Modeling and Programming

The contributions of Simula ...

  The first examples of application frameworks  Class Simulation  A domain specific language with special

syntax

  Automatic memory management  Garbage collection

Models 2010 olm 13

Page 14: A Unified Approach to Modeling and Programming

Some lessons from SIMULA

  SIMULA was created as a means for making simulation models – motivated by operations research

  SIMULA was a general purpose programming language

  SIMULA was used for implementation and analysis and design

  The application domain was reflected in the programs

  No need for structured analysis and structured design   SIMULA was a programming language with a built-in

method

Models 2010 olm 14

Page 15: A Unified Approach to Modeling and Programming

The BETA language

  For modeling and programming   Bent Bruun Kristensen, Ole Lehrmann

Madsen, Birger Møller-Pedersen, Kristen Nygaard

  Generalized abstraction mechanisms  Pattern, virtual class, etc.

  Concurrency, alternation, etc.   An associated conceptual framework   History of Programming Languages III,

San Diego 2007 Models 2010 olm 15

Page 16: A Unified Approach to Modeling and Programming

Benefits of object-orientation

  Unifying perspective on most phases of the software life cycle   Common language core:

class, subclass, virtual, method, etc.   Common conceptual framework

  Good support for modeling   Programs reflect reality (the application

domain) in a natural way

  Good support for programming   Extensibility & reuse

Models 2010 olm 16

Page 17: A Unified Approach to Modeling and Programming

The situation today

  Divergence of modeling and programming   Object-oriented programming:

 Very little attention to modeling   Mainstream modeling:

  Is widening the gap to programming   Executable models:

 The right direction  A long way to go

Models 2010 olm 17

Page 18: A Unified Approach to Modeling and Programming

Models 2010 olm 18 18 © Kristen Nygaard, 2000

OBJECT ORIENTATION: PAST, PRESENT, FUTURE

KRISTEN NYGAARD

"The first duty of a revolutionary is to get away with it."

Abbie Hoffmann

"The first duty of a programmer is to get away with it."

Hackers' Credo

The first duty of a programmer

To program is to understand Kristen Nygaard

Page 19: A Unified Approach to Modeling and Programming

While programmers don’t use UML

  Large and incomprehensible   All you need is code (Nierstrasz)

 The code is the real thing   “Very few real-world objects in my application”   When time becomes critical,

the model is dropped  Difficult to keep the model consistent with the

code   Impedance mismatch,

as with OOA and OOD

Models 2010 olm 19

Page 20: A Unified Approach to Modeling and Programming

The model should be the code

  “There similarly appears to be something fundamentally wrong with model-driven development as it is usually understood — instead of generating code from models, the model should be the code.”

Oscar Nierstrasz: Ten things I hate about object-oriented programming

Banquet speech, ECOOP 2010

Models 2010 olm 20

Page 21: A Unified Approach to Modeling and Programming

Models 2010 olm 21

What is a model?

Page 22: A Unified Approach to Modeling and Programming

Is a UML diagram a model?

Models 2010 olm 22

Page 23: A Unified Approach to Modeling and Programming

Classes drive me crazy ...

“There is a complete disconnect in OOP between the source code and the runtime entities. Our tools don’t help us because our IDEs show us classes, not objects. I think that’s probably why Smalltalkers like to program in the debugger. The debugger lets us get our hands on the running objects and program them directly. Here is my message for tool designers: please give us an IDE that shows us objects instead of classes!”

Oscar Nierstrasz: Ten things I hate about object-oriented programming

Banquet speech, ECOOP 2010

Models 2010 olm 23

Page 24: A Unified Approach to Modeling and Programming

The use of modeling

  Used in many disciplines:  Science, engineering, architecture,

entertainment, software development, ...   For communication of properties of

systems   For understanding properties of existing

systems   For analyzing properties before building

new systems   As toys

Models 2010 olm 24

Page 25: A Unified Approach to Modeling and Programming

Models 2010 olm 25

Primitive societies

  Models are sometimes believed to be useful in their own right

  Manipulation of the model might itself cause corresponding changes in the real world

  Sticking pins into wax models of enemies …

  Example due to Tony Hoare

Page 26: A Unified Approach to Modeling and Programming

Simulation metaphor

  SIMULA describes real systems and generated a simulation

  The simulation is the dynamic structure of objects evolving during execution of the program

  The simulation (program execution) is considered to be the model

  Alan Kay has described object-oriented programming as a view on computation as simulation

Models 2010 olm 26

Page 27: A Unified Approach to Modeling and Programming

Webster:

  A model refers to a small, abstract or actual representation of a planned or existing entity or system from a particular viewpoint.

Models 2010 olm 27

Page 28: A Unified Approach to Modeling and Programming

Abstract or actual

  Abstract: mathematical description

  Newton's laws of motion

  Actual: something physical

  A molecule:

Models 2010 olm 28

Page 29: A Unified Approach to Modeling and Programming

Planned or existing system

Models 2010 olm 29

Model of planned building

Model of (existing) solar system

Page 30: A Unified Approach to Modeling and Programming

From a particular viewpoint

  A good map provides the information we need for a particular purpose – or the information the mapmaker wants us to have

Peter Turchi: Maps of the Imagination – the writer as a cartographer

Models 2010 olm 30

Page 31: A Unified Approach to Modeling and Programming

Description versus model

Models 2010 olm 31

Description: Model:

The (physical) material:

Page 32: A Unified Approach to Modeling and Programming

Models 2010 olm 32

Object-oriented programming

A program execution is regarded as a physical model

simulating the behavior of a real or imaginary system

Page 33: A Unified Approach to Modeling and Programming

Description versus model

  The languages for making descriptions are important

  More attention to the model  Objects, their properties, and actions

  We need tools showing the program execution  More than debuggers

  The semantics of the language

Models 2010 olm 33

Page 34: A Unified Approach to Modeling and Programming

Models 2010 olm 34

Conceptual framework

Page 35: A Unified Approach to Modeling and Programming

The basis for modeling

  We must understand and develop the conceptual means for understanding and organizing knowledge

  Guidelines for identifying  Objects, properties of objects, classes,

class hierarchies, methods, activities (tasks), …

  For understanding the limitations of programming languages

  The theory and semantics of OO

Models 2010 olm 35

Page 36: A Unified Approach to Modeling and Programming

Current situation of modeling

  Mainstream programming languages:   Modeling was never considered seriously   In Smalltalk many classes are not

substitutable   Subclassing: inheritance of code   Multiple inheritance: often complicated

technicalities   Languages with both types and classes

Models 2010 olm 36

Page 37: A Unified Approach to Modeling and Programming

Status of conceptual framework

  SIMULA  Modeling central, but conceptual framework

was implicit   BETA:

 The conceptual framework was developed together with the language

 Test: programming and modeling   Modeling languages:

  I am sure that conceptual framework is considered important

Models 2010 olm 37

Page 38: A Unified Approach to Modeling and Programming

Models 2010 olm 38

Abstraction

  In the development of our understanding of complex phenomena, the most powerful tool available to the human intellect is abstraction

(Tony Hoare, Notes on Data Structuring. In Dahl, Dijkstra, Hoare:

Structured Programming, Academic Press, 1972)

  Identification of phenomena and their properties

  Formation of concepts

Page 39: A Unified Approach to Modeling and Programming

Conceptual means

  Identification of objects   Classification

 Clustering  Generalization/specialization

  Composition/aggregation  Whole/part  Reference composition  Concept composition

  Association

Models 2010 olm 39

Page 40: A Unified Approach to Modeling and Programming

Models 2010 olm 40

Class and concept

  A concept is represented as a class   Intension: attributes and methods   Extension: the instances of the class

Referent system

Concept: Person, ...

Phenomena: Churchill, ...

Model system

Class: Person, ...

Object: Churchill, ...

Page 41: A Unified Approach to Modeling and Programming

Models 2010 olm 41

Concept hierarchies   Subclass

The extension of Car is a subset of the extension of Vehicle   Extends

The intension of Car extends the intension of Vehicle

c1 c2 c3 t1 t2 t3 b1 b2 b3

Car Bus Truck

Vehicle

Page 42: A Unified Approach to Modeling and Programming

Models 2010 olm 42

c1 c2 c3 t1 t2 t3 b1 b2 b3

Car Bus Truck

Vehicle

Tree structured classification

Subclasses with disjoint extensions

Page 43: A Unified Approach to Modeling and Programming

Models 2010 olm 43

re1 re2 re3 sq1 sq2 qs3 rh1 rh2 rh3

Square

Rhomb Rectangle

Parallelogram

Non-tree structured classification Subclasses with overlapping extensions

Page 44: A Unified Approach to Modeling and Programming

Models 2010 olm 44

Profession

Nurse Teacher ...

European

...

Nationality American

...

Asian

Independent tree-structured classifications of the same objects

p1 p2 p3 ... p4 p5 p6 ...

Several classification hierarchies

Page 45: A Unified Approach to Modeling and Programming

Models 2010 olm 45

Objects may change class membership during their existence

LizaLarsen

LizaLarsen

LizaLarsen

time t1

time t2

time t3

Profession

student programmer manager

Dynamic classification

Page 46: A Unified Approach to Modeling and Programming

Models 2010 olm 46

Behavior hierarchies

Travel

Source Destination Duration Vehicle

Part/whole composition

Movement

Travel Jump Run

Generalization/specialization

Travel

Clustering

Columbus's Hannibal's march America-expedition across the Alps

Page 47: A Unified Approach to Modeling and Programming

Models 2010 olm 47

Design patterns: a challenge for abstraction

Program fragment 1

Program fragment 2

Program fragment 3

myDesignPattern: X A

Y Z

Page 48: A Unified Approach to Modeling and Programming

Abstraction mechanisms

  The conceptual framework shows limitations of current abstraction mechanisms:  Class, type, virtual, procedure, generic, etc.

  We should derive new abstraction mechanisms

Models 2010 olm 48

Page 49: A Unified Approach to Modeling and Programming

Properties of phenomena in information systems

  Physical material   Properties of material   Actions

Models 2010 olm 49

Page 50: A Unified Approach to Modeling and Programming

Models 2010 olm 50

Language issues

Page 51: A Unified Approach to Modeling and Programming

Issues

  Syntax   Constraints   Domain specific

languages   Scenario

descriptions   Programming by

examples

  State machines   Associations   Asynchronous

events   Action sequences   Other constructs

Models 2010 olm 51

Page 52: A Unified Approach to Modeling and Programming

Models 2010 olm 52

Record: { … };

Person: Record { … }

Student: Person{ … }

Employee: Person{ … }

Book: Record{ … }

Abstract syntax

tree

Common

Representation

Diagrams and code: different views

Record

Student

Book Person

Employee

•  One to one correspondence

•  No code generation

Page 53: A Unified Approach to Modeling and Programming

A picture says more than a thousand words

  A word says more than a thousand pictures:

Vehicle:

Models 2010 olm 53

Page 54: A Unified Approach to Modeling and Programming

Constraints

  Class invariants,   Pre- and post- conditions   Assertions   Constraint-oriented programming   Useful for programming as well   Modeling/specification work could drive

this

Models 2010 olm 54

Page 55: A Unified Approach to Modeling and Programming

Scenario descriptions

  Emphasis on run-time – the model   UML sequence diagrams, object diagrams,

etc., are steps in the right direction   Should be a part of any programming

language definition   We need a notation for the whole program

execution

Models 2010 olm 55

Page 56: A Unified Approach to Modeling and Programming

Programming by examples

  Derive descriptions / programs from scenarios / examples

  From interaction diagrams to state-machines

  Derivation of programs from examples

Models 2010 olm 56

Page 57: A Unified Approach to Modeling and Programming

State-machines & associations

  The justifying examples for modeling languages

  Issues:  Precise semantics?  Programming language abstraction

mechanisms  Design patterns  Textual or graphical notation  Embedding of graphical language

Models 2010 olm 57

Page 58: A Unified Approach to Modeling and Programming

Asynchronous events and actions

  Relevant for programming as well as modeling

  Sequential actions  The same for programming and modeling

  Concurrency  We need better concurrency abstractions

Models 2010 olm 58

Page 59: A Unified Approach to Modeling and Programming

Concurrency

  Modeling of concurrent processes from the real world was essential for SIMULA

  SIMULA had quasi-parallel processes   Major difference between modeling

languages and programming languages   Challenge:

 Strong need for better mechanisms for modeling and implementing concurrent processes

Models 2010 olm 59

Page 60: A Unified Approach to Modeling and Programming

Executable modeling language

  Must subsume state-of-art from programming languages

  Must be just as efficient as programming languages

  No need for modifying the generated code   Just a new higher level programming

language   A long way to go

Models 2010 olm 60

Page 61: A Unified Approach to Modeling and Programming

Models 2010 olm 61

Summary

Page 62: A Unified Approach to Modeling and Programming

A unified approach

  Language for modeling and programming  Executable  Non-executable

  Model: program execution  Properties, notation, tools

  Conceptual framework

Models 2010 olm 62

Page 63: A Unified Approach to Modeling and Programming

Back to the future

  SIMULA: the strength of a unified approach to modeling and programming is fading away

  Re-unite the forces  Don’t let programmers get away with it  Don’t let modelers just create bubbles

Models 2010 olm 63