model-driven programming education michael e. caspersen department of computer science and centre...
TRANSCRIPT
Model-DrivenProgramming Education
Michael E. CaspersenDepartment of Computer Scienceand Centre for Science Education
Aarhus University, [email protected]
Workshop @ ACE 2013
ACE 2013, Adelaide, AUS Model-Driven Programming Education 2
Three Perspectives on Programming
• Instructing the computer (coding)– the purpose of programming is to instruct the computer– focus is on aspects of program execution such as storage
layout, control flow, parameter passing, etc.
• Managing the program description– the purpose of programming is to create a software architecture
that provides overview and understanding of the entire program– focus is on aspects such as visibility, scope, encapsulation,
modularity, software design etc.
• Conceptual modeling– the purpose of programming is to express concepts, structure
and relations– focus is on constructs for describing concepts, phenomena and
relations between these
ACE 2013, Adelaide, AUS Model-Driven Programming Education 3
Characterization and Expectations
• Characterise the introductory programming course at your home institution– other views on programming?– how are the views balanced in the intro course?– what defines the progression in your intro course?
• What are your expectations for this workshop?
ACE 2013, Adelaide, AUS Model-Driven Programming Education 4
Contents and Progression• Traditional approach
– typical textbooks only address the first and to some extend the second perspective
– topics are organized according to the syntactical structures in the programming language (bottom-up)
– tendency to completeness in coverage of topics– syntax-driven progression
• Our approach– a balanced coverage of all three views– conceptual modeling is leading the way– systematic programming (no more pulling rabbits out of the hat)– early bird & spiral approach– model-driven progression
5
Sample Exam Assignment
PlaylistString playlistNamevoid addTrack(Track t)void removeTrack(Track t)Track findShortestTrack()List<Track> find(String s)void printSortedTracks()
*
TrackString artistString songNameint minint secString toString()
Drivervoid exam()
1. Create a simple class Track ... with constructor and a toString method…
2. Create a test method exam…3. Create two instancies…4. Create a new class Playlist ...5. Implement the methods addTrack
and removeTrack6. Modify the test method to create a
Playlist object…7. Implement and test method
findShortestTrack8. Implement and test method
findTracksByArtist …9. Let the Track class implement
interface Comparable …10. Implement the method
printSortedTracks and modify ...
ACE 2013, Adelaide, AUS Model-Driven Programming Education
6
The ”Complete” Model
PlaylistString playlistNamevoid addTrack(Track t)void removeTrack(Track t)Track findShortestTrack()List<Track> find(String s)void printSortedTracks()
TrackString artistString songNameint minint secString toString()
Drivervoid exam()
Collectionsvoid sort(List l)
Comparableint compareTo(T e)
Java’s Collections Framework
*
ACE 2013, Adelaide, AUS Model-Driven Programming Education
<<implements>>
Learning Goals and Examination Form
• By the end of the course the students must be able to– apply fundamental constructs in an ordinary PL– explain the architecture of simple programs– explain the semantics of simple specification models– implement simple specification models in an ordinary PL– apply selected classes from a standard class library
ACE 2013, Adelaide, AUS Model-Driven Programming Education 7
Oral Exam
Written Exam
Multiple Choice
Practical Exam
Alignment
Weekly mandatory assignments prepare the students for the exambut don’t count in the final grading
ACE 2013, Adelaide, AUS Model-Driven Programming Education 8
Course Context and Structure
A Quarter (7 weeks)
1
2
3
4
5
6
7
Q2
Q3
Q4
An Academic Year
Q1
Progression
Complexity of class models (language stuff added by need)
9
Course Phases (week numbers)(1) Getting started
Overview of fundamental concepts. Learning the IDEs and other tools.
(2) Introduction to the basicsClass, object, state, behaviour, control structures.
(3-4) Conceptual framework and structural patterns Control structures, data structures (collections),
class relationship, patterns for implementingstructure (association).
(4-5) Programming methodSTREAM, patterns for implementing functionality
(algorithmic patterns).
(6) Subject specific assignmentPractice on harder problems.
(7 (+ 8-9)) PracticeAchieve routine in solving standard tasks (prep for exam).
ACE 2013, Adelaide, AUS Model-Driven Programming Education
ACE 2013, Adelaide, AUS Model-Driven Programming Education 10
Key Points (and Agenda)• Conceptual modelling
– Conceptual modelling is the defining characteristic of OO
• Progression– Progression in terms of complexity of class models (not
syntax of a programming language)
• Systematic programming– Systematic programming revealed through basic (structural and
algorithmic) patterns and STREAM (a programming method for novices)
• Learning-theoretic foundation– A learning-theoretic foundation (Cognitive Load Theory,
Cognitive Apprenticeship, and Worked Examples)
ACE 2013, Adelaide, AUS Model-Driven Programming Education 11
References1. O.L. Madsen, B. Møller-Pedersen and K. Nygaard (1993): Object-Oriented
Programming in the BETA Programming Language, Addison-Wesley. [ Link ]
2. M.E. Caspersen (2007), Educating Novices in the Skills of Programming, DAIMI PhD Dissertation PD-07-4, ISSN 1602-0448 (paper), 1602-0456 (online). [ Link ]
3. M.E. Caspersen and J.B. Bennedsen (2007), Instructional Design of a Programming Course: A Learning-Theoretic Approach, Proceedings of the 3rd International Computing Education Research Workshop, ICER 2007, Atlanta, GA, USA, September 2007, pp. 111-122. [ Link ]
4. J.B. Bennedsen and M.E. Caspersen (2007), Assessing Process and Product — A Practical Lab Exam for an Introductory Programming Course, Innovation in Teaching and Learning in Information and Computer Sciences, Vol. 6 (4), Special Issue on Innovative Methods of Teaching Programming, pp. 183-202. [ Link ]
5. J.B. Bennedsen, M.E. Caspersen and M. Kölling (2008), Reflections on the Teaching of Programming, Lecture Notes in Computer Science, Vol. 4821, Springer-Verlag. [ Link, ToC ]
6. J. B. Bennedsen and M.E. Caspersen (2008), Model-Driven Programming, in [5], pp. 116-129. [ Link ]
7. M.E. Caspersen and M. Kölling (2009), STREAM: A First Programming Process, ACM Transactions on Computing Education (TOCE), Vol. 9 (1), Article No. 4, pp. 1-29. [ Link ]
A Conceptual Framework forObject-Oriented Programming
There is more to OO than Java...
ACE 2013, Adelaide, AUS Model-Driven Programming Education 13
Kristen Nygaard on Object-Orientation
A program execution is regarded as a physical model system simulating the behavior of either a real or imaginary part of the world.
Physical modeling is based upon the conception of reality in terms of phe-nomena and concepts.
A physical model system is construc-ted, modeling phenomena by objects and concepts by categories of objects.
Kristen Nygaard, 1926-2002
An Interlude on Concepts
ACE 2013, Adelaide, AUS Model-Driven Programming Education 14
What is a concept?
ACE 2013, Adelaide, AUS Model-Driven Programming Education 15
Concepts and phenomenons of EPR
• Electronic Patient Record (EPR)
– Patient (Lance Armstrong, John Kerry, ...)
– Treatment (bandaging, rest, physical therapy, ...)
– Diagnosis (sprained wrist, broken leg, yellow fever, ...)
– Operation (removing the appendix, sterilization, brain surgery, ...)
– Doctor (Beth Barry, Lou Lazanta, ...)
– Nurse (Jane Clemenza, Laura Hopcroft, ...)
ACE 2013, Adelaide, AUS Model-Driven Programming Education 16
Model of EPR
Problem domain Model
Doctor
Patient Diagnosis
Treatment
SeniorDoctor
JuniorDoctor
...
*
1
*
*
ACE 2013, Adelaide, AUS Model-Driven Programming Education 17
Conceptual Modelling
Conceptual model(problem-specific
concepts)
Problem/vision concerning phenomena
Specification model (realised concepts)
Objects (program, language, OS,
machine)
abstraction abstraction
modelling
Problem domain Model
ACE 2013, Adelaide, AUS 18
Phenomena and Concepts
• A phenomenon is– a thing that has definite, individual existence in reality or in the
mind; anything real in itself
• A concept is– a generalised idea of a collection of phenomena, based on
knowledge of common properties of instances in the collection
Model-Driven Programming Education
ACE 2013, Adelaide, AUS 19
Characterisation of Concepts
• Designation– The collection of names (or pictures) by which the concept is
known
• Extension– The collection of phenomena that the concept somehow covers
• Intension– The collection of properties that in some way characterize the
phenomena in the extension of the concept
Model-Driven Programming Education
ACE 2013, Adelaide, AUS 20
Examples of Concepts
Designation Extension Intension
Horse
Car
Rectangle
Food
Model-Driven Programming Education
ACE 2013, Adelaide, AUS 21
Aristotelian View
• Characterisation (intension :-)– The intension is a collection of properties that may be divided
into two groups• defining properties that all phenomena in the extension must have• characteristic properties that the phenomena may have
– Well-defined concepts with sharp borders– Relatively homogeneous phenomena– The extension is uniquely determined by the intension
(objectively determinable)
• Examples (extension :-)– Does to some extend exist in well-established topic areas such
as mathematics, physics, zoology, botany, ...
Model-Driven Programming Education
ACE 2013, Adelaide, AUS 22
Prototypical View
• Characterisation (intension :-)– The intension of a concept consists of examples of properties
that phenomena may have, together with a collection of typical phenomena covered by the concept: prototypes
– Blurry concepts with vague borders– Great variation among phenomena– The extension is not uniquely determined by the intension
• Examples (extension :-)– Everywhere!
Model-Driven Programming Education
ACE 2013, Adelaide, AUS 23
Conceptual Modelling, revisited
• Problem Specific Concepts (PSC) are almost always of prototypical nature
• Realised Concepts (RC) are Aristotelian (because of our programming languages)
• This mismatch represents a challenge for modelling– to give an Aristotelian definition to prototypical concepts
Problem domain Model
RCPSC
Model-Driven Programming Education
ACE 2013, Adelaide, AUS Model-Driven Programming Education 24
Concept Formation• Identification of phenomena
– Socrates– Batmobile– Hannibal’s march across the Alps– Neil Young– Sirius 2000– Herbie– Hillary Clinton
• Classification
Person
SocratesNeil Hillary
Car
Batmobile Herbie
Journey
Sirius 2000 Hannibal’s march across the Alps
ACE 2013, Adelaide, AUS Model-Driven Programming Education 25
Classification in UMLClasses represent concepts,objects represent phenomena
Example Concept: PersonPhenomena: Bruce, Paul, Michael
Person
isTeenager()isOld()age()
String nameint age
Class
: Person”Bruce”
63 : Person”Paul”
70: Person”Michael”
52
Objects
ACE 2013, Adelaide, AUS Model-Driven Programming Education 26
Classification in Java
class Person { private String name; private int age;
public Person(String name, int age) { this.name = name; this.age = age; }
public void birthday() { age++; }
public isTeenager() { return (age >= 13 && age <= 19) }}
List l = new ArrayList();
l.add( new Person(”Bruce”, 63) ); l.add( new Person(”Paul”, 70) ); l.add( new Person(”Michael”, 52) );
ACE 2013, Adelaide, AUS Model-Driven Programming Education 27
Relations between concepts
• Aggregation– has-a
• Association– X-a
• Generalization/specialization– is-a
Organization of knowledge...
ACE 2013, Adelaide, AUS Model-Driven Programming Education 28
Aggregation (has-a)
Relation between concepts describing a whole and (some of) the parts which constitutes the whole (part-whole structure).
UML: Composition
Car
Motor Wheel Body Seat
Door Roof Fender
Journey
Departure DestinationDuration Means oftransportation
ACE 2013, Adelaide, AUS Model-Driven Programming Education 29
Aggregation in UML (1)
ClockDisplay
timeTick()setTime(int h, int m)getTime(): String
NumberDisplay hours;NumberDisplay minutes;String displayString;
ACE 2013, Adelaide, AUS Model-Driven Programming Education 30
Aggregering i UML (2)
ClockDisplay
timeTick()setTime(int h, int m)getTime(): String
NumberDisplay
getValue()getDisplayValue()setValue()increment()
int limit;int value;String displayString;
2
ACE 2013, Adelaide, AUS Model-Driven Programming Education 31
Aggregation in Java
class NumberDisplay { private int limit, value;
public NumberDisplay() { ... } public int getValue() { ... } public String getDisplayValue() { ... } public void setValue(int replacementValue) { ... } public void increment() { ... }}
class ClockDisplay { private NumberDisplay hours; private NumberDisplay minutes; private String displayString;
public ClockDisplay() { hours = new NumberDisplay(24); minutes = new NumberDisplay(60); } public void timeTick() { ... } public void setTime(int hour, int minutes) { ... } public String getTime() { ... }}
ACE 2013, Adelaide, AUS Model-Driven Programming Education 32
Association (X-a)
Relation that describes a dynamic relation between concepts where the phenomena exist independently of each other and just occasionally are associated.
MailServer keeps MailItem
Person owns CarPerson rents Car
Person loves PersonPerson is-friend-with Person
Student is-enrolled-at Course
Patient have-had Disease
ACE 2013, Adelaide, AUS Model-Driven Programming Education 33
Association in UML
Person Car
MailServer MailItem
Student Course
*keeps
*owns
0..1 owned
*
takes
*
Multiplicity (cardinality): 0..1, 1, n, a..b, 0..* (*)
Role
Orientation (1-way, 2-way)
can-drive *
ACE 2013, Adelaide, AUS Model-Driven Programming Education 34
Association in UML (X-a)
MailServer
howManyMessages(String who): intgetNextMailItem(String who): MailItempost(MailItem item)
MailItem
getFrom(): StringgetTo(): StringgetMessage(): Stringprint()
0..*
X = keeps
from: Stringto: Stringmessage: String
ACE 2013, Adelaide, AUS Model-Driven Programming Education 35
Association in Java
class MailItem {
private String to; private String from; private String message;
public MailItem( ... ) { ... }
public String getFrom() { ... } public String getTo () { ... } public String getMessage() { ... } public void print() { ... }}
class MailServer {
private List messages;
public MailServer() { messages = new ArrayList(); }
public int howManyMessages (String who) { ... }
public MailItem getNextMailItem (String who) { ... }
public void post(MailItem item) { ... }}
ACE 2013, Adelaide, AUS Model-Driven Programming Education 36
Generalization/specialization (is-a)
Combine concepts to a more general concept.
Vehicle
TruckCar Bus
TaxiPassenger car Ambulance
Van Sedan
ACE 2013, Adelaide, AUS Model-Driven Programming Education 37
What makes a concept special?Means of transportation Plane Passenger plane Airliner Sports plane Military plane Ship Vehicle Car Bus Truck Lorry Pick-up Truck Passenger car Van Taxi Bicycle
Figure Ellipse Circle Triangle Isosceles triangle Equilateral Right-angled Four-sided polygon Trapezoid Parallelogram Rectangle Square Kite
Additional properties!
ACE 2013, Adelaide, AUS Model-Driven Programming Education 38
Specialization: extra properties
A
B
B is-a A
Intension(A) Intension(B)
Extension(B) Extension(A)
A concept’s intension: The collection of propertiescharacterising the concept
A concept’s extension: The collection of phenomenacovered by the concept
ACE 2013, Adelaide, AUS Model-Driven Programming Education 39
Specialization in UML
LendableItem
lend(l: borrower)return()isAvalable()
Book
author()publisher()ISBN()
Video
producer()format()playingTime()
Generalconcept
Specialconcepts
ACE 2013, Adelaide, AUS Model-Driven Programming Education 40
Specialization in Java
class LendableItem { void lend(Borrower b) { // code for lend }
void return() { // code for return }
boolean isAvalable() { // code for isAvalable }
...}
class Book extends LendableItem { String author() { ... } String puclisher() { ... } String ISBN() { ... } ...}
class Video extends LendableItem { String producer() { ... } String format() { ... } int playingTime() { ... } ...}
ACE 2013, Adelaide, AUS Model-Driven Programming Education 41
Concept formation and OO-languages
• Classification
• Aggregation– has-a
• Association– X-a
• Specialization– is-a
• class
• Reference (attribute)– aggregate has responsibility for
the creation
• Reference (attribute)– dynamic relation
• extends– subtype
ACE 2013, Adelaide, AUS Model-Driven Programming Education 42
Summary• Conceptual framework for object-orientation
– Concepts and modelling– Structure: aggregation, association, specialization– is used for organizing knowledge about a problem domain
and structure in the solution domain– Is (to some extend) supported by language constructs in OO
languages
• Modelling examples– Abstract models in UML– Implementation in Java– Examples from textbook [Barnes & Kölling] – which does not
explicitly present the models...
Model-Driven Programming
Programming in Context
ACE 2013, Adelaide, AUS Model-Driven Programming Education 44
Hand-in-Hand Modeling and Coding (1)
• David Gries (Edsger W. Dijkstra)– the loop body and the loop invariant is developed hand-in-hand
with the latter leading the way
• We (Kristen Nygaard)– coding and class modeling is done hand-in-hand with the latter
leading the way
• Design by contract and systematic programming– a class model is a design contract in precisely the same way
as a loop invariant is– code is introduced on purpose (fulfilling the contract)
ACE 2013, Adelaide, AUS Model-Driven Programming Education 45
Intermezzo: Contracts at Four Levels
• Model– relations between classes (interfaces)– association, aggregation/copmposition, specialization
• Interface (spec)– functional specification (pre and post conditions)
• Class (impl)– class invariant (representation invariant)
• Method– assertions (loop invariant)
• Systematic programming– systematic techniques associated with each level
ACE 2013, Adelaide, AUS Model-Driven Programming Education 46
Systematic Implementation Techniques
• Inter-class structure– implementation of specification model using standard patterns
for implementing relations between classes
• Intra-class structure– implementation of interface or class specifications using
STREAM– implementation using class invariants
• Methods– algorithmic patterns (sweep, search, divide and conquer, ...)– loop invariant techniques
Separation of concerns...
ACE 2013, Adelaide, AUS Model-Driven Programming Education 47
Intermezzo: Contracts at Four Levels
• Model– relations between classes (interfaces)– association, aggregation/copmposition, specialization
• Interface (spec)– functional specification (pre and post conditions)
• Class (impl)– class invariant (representation invariant)
• Method– assertions (loop invariant)
• Systematic programming– systematic techniques associated with each level
Our focustoday
ACE 2013, Adelaide, AUS Model-Driven Programming Education 48
Hand-in-Hand Modeling and Coding (2)
Person
name
...
ACE 2013, Adelaide, AUS Model-Driven Programming Education 49
Hand-in-Hand Modeling and Coding (2)
class Person { private String name;
public Person(String name) { this.name = name;
}
...}
Person
name
...
ACE 2013, Adelaide, AUS Model-Driven Programming Education 50
Hand-in-Hand Modeling and Coding (2)
Person
class Person { private String name;
public Person(String name) { this.name = name;
}
...}
lover
0..1
ACE 2013, Adelaide, AUS Model-Driven Programming Education 51
Hand-in-Hand Modeling and Coding (2)
Person
class Person { private String name; private Person lover;
public Person(String name) { this.name = name; lover = null;
}
public fallsInLoveWith(Person p) ...
...}
lover
0..1
ACE 2013, Adelaide, AUS Model-Driven Programming Education 52
Hand-in-Hand Modeling and Coding (2)
Person
class Person { private String name; private Person lover;
public Person(String name) { this.name = name; lover = null;
}
public fallsInLoveWith(Person p) ...
...}
lover
0..1
spouse
0..1
ACE 2013, Adelaide, AUS Model-Driven Programming Education 53
Hand-in-Hand Modeling and Coding (2)
Person
class Person { private String name; private Person lover; private Person spouse;
public Person(String name) { this.name = name; lover = null; spouse = null;
}
public fallsInLoveWith(Person p) ... public marries(Person p) ...
...}
lover spouse
0..1 0..1
ACE 2013, Adelaide, AUS Model-Driven Programming Education 54
Hand-in-Hand Modeling and Coding (2)
Person
class Person { private String name; private Person lover; private Person spouse;
public Person(String name) { this.name = name; lover = null; spouse = null;
}
public fallsInLoveWith(Person p) ... public marries(Person p) ...
...}
lover spouse
friends
0..1
*
0..1
ACE 2013, Adelaide, AUS Model-Driven Programming Education 55
Hand-in-Hand Modeling and Coding (2)
Person
class Person { private String name; private Person lover; private Person spouse; private List friends;
public Person(String name) { this.name = name; lover = null; spouse = null; friends = new ArrayList(); }
public fallsInLoveWith(Person p) ... public marries(Person p) ... public becomesFriendWith(Person p) ... ...}
lover spouse
friends
0..1
*
0..1
ACE 2013, Adelaide, AUS Model-Driven Programming Education 56
Example: Telstra Lite
Customer Subscription1 * Transaction*
PaymentCall
MMS SMS
Conversation
Image Sound
Video
MMObject *
ACE 2013, Adelaide, AUS Model-Driven Programming Education 57
Model-Driven Programming
• Model-driven– programming tasks starts from a class model– mostly, the model is given– sometimes, also (a part of) the model must be developed– Incremental development: Stepwise Improvement (STREAM)
• Progression– models become increasingly complex during the course– associated systematic programming techniques– language issues covered “by need” (introduced very early)
ACE 2013, Adelaide, AUS Model-Driven Programming Education 58
Course Progression
Conceptual Model
Problem/vision
Specification Model
Implementation Model
Analysis Implementation
Design
Reference System Model System
ACE 2013, Adelaide, AUS Model-Driven Programming Education 59
Course Progression
Conceptual model
Problem/vision
Specification model
Implementation model
Analysis Implementation
Design
Problem domain Model
60
Model-Based Progression
A
Stand-alone class
Shape, Turtle, Person, Die, Date, Heater, Account, ...
A
Simple association and composition
B A B22
DieCup, ClockDisplay, ...
A
Recursive Association0..1
A*
Person (lover and fiancee),Person (friends)
Animal (parents, brood), ...
A
Association (to another class)
B A B*0..1
Car-Person (isOwnedBy),Track-Playlist (contains)
Implementing an interface
A B*
IComparable and ComparatorUse of Collections.sort(), etc.
61
Faded Guidance and Cognitive Apprenticeship
3. A lab session follows where the students interact with, modify, and extend both examples.
1. In a lecture we present an example of development of a program with two classes, Playlist and Track. P T*
2. A video presentation of a partial development of a similar example (say Account and Transaction) is made available.
A T*
4. A follow-up exercise is provided where the students extend the Playlist-Track example by adding an Image
class.
P T*
I*
5. In the following week we give a mandatory assignment where the students implement a system of three classes,
say Notebook, Note, and Keyword.
Nb N*
K*
Worked examples with high variability increase cognitiv
e load and
learning (if intrin
sic cognitive load is suffic
iently low).
Variability
effect, 1
994 ( Germ
ane Cognitive Load)
Example
ACE 2013, Adelaide, AUS Model-Driven Programming Education 62
Exercise• Create one or two exercises by concretizing the
following models:
A B*
A B2
A B*
B1 B2
a)
b)
c)
ACE 2013, Adelaide, AUS Model-Driven Programming Education 63
Motivating and Engaging Problems
• Real-world examples– no factorial– no fibonacci numbers
• Multimedia– image and sound processing
• Mobile technology– cell phones– PDAs– MP3-players
• Internet technology– web browser
• Sample projects– Turtle Graphics– Die, Dice-cup– Date– Personal relations– Musician-Band-Festival– Car rental– Library (lending of books)– Banking (accounts, etc.)– Image and sound processing– Text processing (hyphenation)– Synchronizing calenders– MP3-player (track, tracklist, ...)– Web browser– ...
ACE 2013, Adelaide, AUS Model-Driven Programming Education 64
Assessment (Varying Cover Story)
Track * Playlist
Luggage * Flight
TextFile * Directory
Magazine * Subscriber
Card * Deck
Employee * Department
Diagnosis * Person
Plant * Allotment
SideEffect * Medicine
Picture * MemoryCard
TimeSheet * HourlyPaid
Instrument * Musician
65
Principles of Programming Education
Practice consume before produce
Present worked, exemplary examples
Reinforce patterns and conceptual frameworks
...
Method Class Model
Use 1 1 1
Modify 2 3 4
Create 5 6 7
Allows more interesting things to be done.
Helps separate spec and impl.
Applies at many levels (code specification, class libraries,
design patterns, frameworks, ...)
66
Course Phases(1) Getting started: Overview of
fundamental concepts. Learning the IDEs and other tools.
(2) Introduction to the basics: Class, object, state, behaviour, control structures.
(3) Conceptual framework and patterns: Control structures, data structures
(collections), class relationship, patterns for implementing structure (association).
(4) Programming method: STREAM, patterns for implementing functionality
(algorithmic patterns).
(5) Subject specific assignment: Practice on harder problems.
(6) Practice: Achieve routine in solving standard tasks (prep for exam).
Method modifyMethod create
Class modify
Method use
Class create
Class create
Class create
Re
du
ce e
xtran
eo
us C
L In
crea
se g
erm
an
e C
L (pa
ttern
s)
Co
gn
itive a
pp
ren
ticesh
ip (to
reve
al p
roce
ss)
Wo
rked
exa
mp
les a
nd
fad
ed
gu
ida
nce
Co
gn
itive skill
acq
uisitio
n a
nd
a
uto
ma
tionACE 2013, Adelaide, AUS Model-Driven Programming Education
ACE 2013, Adelaide, AUS Model-Driven Programming Education 67
Benefits of MDP
The integrated approachmotivate and support students
in their understanding and practice ofthe programming process
The integration ofconceptual modeling and coding provides
structure, traceability, and a systematic approach toprogram development
ACE 2013, Adelaide, AUS Model-Driven Programming Education 68
Wrapping Up: Key Points
• Conceptual modeling– the defining characteristic of object-orientation
• Model-Driven Programming– programming tasks take-off from a class model– coding and conceptual modeling is done hand-in-hand with the
latter leading the way
• Progression– driven by complexity in class models– stressing associated techniques of systematic programming– language issues covered by need
ACE 2013, Adelaide, AUS Model-Driven Programming Education 69
Key Points (and Agenda)• Conceptual modelling
– Conceptual modelling is the defining characteristic of OO
• Progression– Progression in terms of complexity of class models (not
syntax of a programming language)
• Systematic programming– Systematic programming revealed through basic (structural and
algorithmic) patterns and STREAM (a programming method for novices)
• Learning-theoretic foundation– A learning-theoretic foundation (Cognitive Load Theory,
Cognitive Apprenticeship, and Worked Examples)
Model-DrivenProgramming Education
Michael E. Caspersen
Department of Computer Science
and Centre for Science Education
Aarhus University, Denmark
Workshop @ ACE 2013
Structure (for planning only)
ACE 2013, Adelaide, AUS Model-Driven Programming Education 71
Topic Key point Activity
Intro Exam and main points Introduction
Concepts and conceptual modeling
CM is a defining characteristic of OO
What is a concept?
Didactical design Progression in terms of complexity of class models, not syntax of a language
Design an exercise for a given generic class model
Algorithm vs. structure Lennon & McCartneyStan & LaurelAlice and Randy PauschACE and Mats Daniels
Find loop-based algorithms for the concrete structure from above
Forest and trees Code comprehension is not trivial! Beacons in the code is a necessity (assertions).
What does this program do? (three simple examples: one trivial and two hard ones)
Systematic programming Patterns and methodology (STREAM)
Identify other basic patterns
Parameterization Fundamental design tool Find good examples...
ACE 2013, Adelaide, AUS Model-Driven Programming Education 72
Programs as models
It’s not the purpose of our programsto instruct the computer;
it’s the purpose of the computerto execute our programs
E.W. Dijkstra
A program execution is regarded asa physical model system
K. Nygaard
73
Pattern-Based Instruction
MotivationPatterns capture chunks of programming knowledge and skills.
Reinforces schema creation when cognitive load is “controlled” (+germane cognitive load).
(Cognitive science and educational psychology)
OriginIdeas similar to pattern-based instruction can be traced back to
Mayer (1981), Soloway (1986), Rist (1989), Linn & Clancy (1992).
East et al. (1996) and Wallingford (1996) were among the first to accept the challenge put forward by Soloway.
Soon, others followed, e.g. Astrachan et al. (1997, 1998),Reed (1998), Bergin (2000).
ACE 2013, Adelaide, AUS Model-Driven Programming Education
ACE 2013, Adelaide, AUS Model-Driven Programming Education 74
Systematic Implementation Techniques
• Inter-class structure– implementation of specification model using standard patterns
for implementing relations between classes
• Intra-class structure– implementation of interface or class specifications using
STREAM– implementation using class invariants
• Method structure– algorithmic patterns (sweep, search, divide and conquer, ...)– loop invariant techniques
Separation of concerns...
75
Patterns at Two Levels
Inter-class structureStandard coding patterns for the implementation of relations
between classes.
Intra-class structureClass invariants and
techniques for evaluating these.
Method structureAlgorithmic patterns,
elementary patterns and loop invariants.
Association patternAggregation patternSpecialization pattern
Sweep patternSearch patternDivide, solve, and combine...
ACE 2013, Adelaide, AUS Model-Driven Programming Education