ppt

advertisement
Model-Driven
Programming Education
Workshop @ ACE 2013
Michael E. Caspersen
Department of Computer Science
and Centre for Science Education
Aarhus University, Denmark
mec@cse.au.dk
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
2
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
3
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
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
4
Sample Exam Assignment
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 removeTrack
6. Modify the test method to create a
Playlist object…
7. Implement and test method
findShortestTrack
8. Implement and test method
findTracksByArtist …
9. Let the Track class implement
interface Comparable …
10. Implement the method
printSortedTracks and modify ...
ACE 2013, Adelaide, AUS
Track
String artist
String songName
int min
int sec
String toString()
*
Playlist
String playlistName
void addTrack(Track t)
void removeTrack(Track t)
Track findShortestTrack()
List<Track> find(String s)
void printSortedTracks()
Model-Driven Programming Education
Driver
void exam()
5
The ”Complete” Model
Java’s Collections Framework
Collections
Comparable
void sort(List l)
int compareTo(T e)
<<implements>>
Playlist
String playlistName
void addTrack(Track t)
void removeTrack(Track t)
Track findShortestTrack()
List<Track> find(String s)
void printSortedTracks()
*
Track
String artist
String songName
int min
int sec
String toString()
Driver
void exam()
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
6
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
Oral
Exam
Written
Exam
Multiple
Choice
Practical
Exam
Weekly mandatory assignments prepare the students for the exam
but don’t count in the final grading
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
7
Course Context and Structure
An Academic Year
A Quarter (7 weeks)
1
Q1
2
Q2
3
Q3
4
Q4
5
Progression
6
Complexity of class models
(language stuff added by need)
7
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
8
Course Phases (week numbers)
(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-4) Conceptual framework and structural patterns
Control structures, data structures (collections),
class relationship, patterns for implementing
structure (association).
(4-5) Programming method
STREAM, patterns for implementing functionality
(algorithmic patterns).
(6) Subject specific assignment
Practice on harder problems.
(7 (+ 8-9)) Practice
Achieve routine in solving standard tasks (prep for exam).
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
9
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
10
References
1.
2.
3.
4.
5.
6.
7.
O.L. Madsen, B. Møller-Pedersen and K. Nygaard (1993): Object-Oriented
Programming in the BETA Programming Language, Addison-Wesley. [ Link ]
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 ]
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 ]
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 ]
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 ]
J. B. Bennedsen and M.E. Caspersen (2008), Model-Driven Programming, in
[5], pp. 116-129. [ Link ]
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 ]
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
11
A Conceptual Framework for
Object-Oriented Programming
There is more to OO than Java...
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 phenomena and concepts.
A physical model system is constructed, modeling phenomena by objects
and concepts by categories of objects.
Kristen Nygaard, 1926-2002
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
13
An Interlude on Concepts
What is a concept?
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
14
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
15
Model of EPR
Patient
* Diagnosis
*
1
*
Doctor
Treatment
...
Senior
Doctor
Problem domain
ACE 2013, Adelaide, AUS
Junior
Doctor
Model
Model-Driven Programming Education
16
Conceptual Modelling
Conceptual model
(problem-specific
concepts)
modelling
Specification model
(realised concepts)
abstraction
abstraction
Problem/vision
concerning
phenomena
Objects (program,
language, OS,
machine)
Problem domain
Model
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
17
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
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
18
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
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
19
Examples of Concepts
Designation
Extension
Intension
Horse
Car
Rectangle
Food
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
20
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, ...
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
21
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!
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
22
Conceptual Modelling, revisited
PSC
RC
Problem domain
Model
• 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
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
23
Concept Formation
• Identification of phenomena
–
–
–
–
–
–
–
Socrates
Batmobile
Hannibal’s march across the Alps
Neil Young
Sirius 2000
Herbie
Hillary Clinton
Person
Neil
Socrates
Hillary
Car
Batmobile
• Classification
Herbie
Journey
Sirius 2000
ACE 2013, Adelaide, AUS
Hannibal’s march across the Alps
Model-Driven Programming Education
24
Classification in UML
Classes represent concepts,
objects represent phenomena
Example
Concept: Person
Phenomena: Bruce, Paul, Michael
Class
Objects
Person
String name
int age
: Person
”Bruce”
63
isTeenager()
isOld()
age()
: Person
”Michael”
52
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
: Person
”Paul”
70
25
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()
{ ArrayList();
List l = new
age++;
}
l.add( new Person(”Bruce”, 63) );
l.add( new Person(”Paul”, 70) );
public isTeenager()
l.add( {new Person(”Michael”, 52) );
return (age >= 13 && age <= 19)
}
}
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
26
Relations between concepts
• Aggregation
– has-a
• Association
– X-a
• Generalization/specialization
– is-a
Organization of knowledge...
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
27
Aggregation (has-a)
Relation between concepts
describing a whole and (some of)
the parts which constitutes the
whole (part-whole structure).
Car
Motor
Wheel
Body
Seat
Door
Roof
Fender
UML: Composition
Journey
Duration Departure
ACE 2013, Adelaide, AUS
Means of
Destination
transportation
Model-Driven Programming Education
28
Aggregation in UML (1)
ClockDisplay
NumberDisplay hours;
NumberDisplay minutes;
String displayString;
timeTick()
setTime(int h, int m)
getTime(): String
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
29
Aggregering i UML (2)
NumberDisplay
ClockDisplay
String displayString;
int limit;
int value;
2
getValue()
getDisplayValue()
setValue()
increment()
timeTick()
setTime(int h, int m)
getTime(): String
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
30
Aggregation in Java
class NumberDisplay {
private int limit, value;
public NumberDisplay() { ... }
public int getValue() { ... }
public String getDisplayValue() { ... }
public void setValue(int replacementValue) { ... }
class ClockDisplay {
public void increment() { ... }
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
31
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 Car
Person rents Car
Person loves Person
Person is-friend-with Person
Student is-enrolled-at Course
Patient have-had Disease
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
32
Association in UML
MailServer
Person
keeps
*
owns
*
0..1
owned
can-drive
MailItem
Car
*
takes
Student
*
*
Course
Multiplicity (cardinality): 0..1, 1, n, a..b, 0..* (*)
Role
Orientation (1-way, 2-way)
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
33
Association in UML (X-a)
X = keeps
MailItem
MailServer
0..*
howManyMessages(String who): int
getNextMailItem(String who): MailItem
post(MailItem item)
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
from: String
to: String
message: String
getFrom(): String
getTo(): String
getMessage(): String
print()
34
Association in Java
class MailServer {
class MailItem {
private List messages;
private String to;
private String from;
private String message;
public MailServer() {
messages = new ArrayList();
}
public MailItem( ... ) {
...
}
public int
howManyMessages (String who)
{ ... }
public String getFrom()
{ ... }
public String getTo ()
{ ... }
public String getMessage()
{ ... }
public void print()
{ ... }
public MailItem
getNextMailItem (String who)
{ ... }
public void
post(MailItem item)
{ ... }
}
}
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
35
Generalization/specialization (is-a)
Combine concepts to a more
general concept.
Vehicle
Car
Passenger car
Van
ACE 2013, Adelaide, AUS
Taxi
Truck
Bus
Ambulance
Sedan
Model-Driven Programming Education
36
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
ACE 2013, Adelaide, AUS
Figure
Ellipse
Circle
Triangle
Isosceles triangle
Equilateral
Right-angled
Four-sided polygon
Trapezoid
Parallelogram
Rectangle
Square
Kite
Additional properties!
Model-Driven Programming Education
37
Specialization: extra properties
A concept’s intension:
The collection of properties
characterising the concept
A concept’s extension:
The collection of phenomena
covered by the concept
A
B is-a A
Intension(A)  Intension(B)
B
ACE 2013, Adelaide, AUS
Extension(B)  Extension(A)
Model-Driven Programming Education
38
Specialization in UML
LendableItem
General
concept
lend(l: borrower)
return()
isAvalable()
Book
Special
concepts
ACE 2013, Adelaide, AUS
author()
publisher()
ISBN()
Model-Driven Programming Education
Video
producer()
format()
playingTime()
39
Specialization in Java
class LendableItem {
void lend(Borrower b) {
// code for lend
}
void return() {
// code for return
}
boolean isAvalable() {
// code for isAvalable
}
...
}
ACE 2013, Adelaide, AUS
class Book extends LendableItem
{
String author() { ... }
String puclisher()
{ ... }
String ISBN()
{ ... }
...
}
class Video extends LendableItem
{
String producer() { ... }
String format()
{ ... }
int playingTime()
{ ... }
...
}
Model-Driven Programming Education
40
Concept formation and OO-languages
• Classification
• class
• Aggregation
• Reference (attribute)
– has-a
• Association
– X-a
• Specialization
– is-a
ACE 2013, Adelaide, AUS
– aggregate has responsibility for
the creation
• Reference (attribute)
– dynamic relation
• extends
– subtype
Model-Driven Programming Education
41
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...
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
42
Model-Driven Programming
Programming in Context
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
44
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
45
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
46
Intermezzo: Contracts at Four Levels
• Model
– relations between classes (interfaces)
– association, aggregation/copmposition, specialization
Our focus
today
• 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
47
Hand-in-Hand Modeling and Coding (2)
Person
name
...
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
48
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
49
Hand-in-Hand Modeling and Coding (2)
class Person {
private String name;
lover
0..1
public Person(String name) {
this.name = name;
Person
}
...
}
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
50
Hand-in-Hand Modeling and Coding (2)
class Person {
private String name;
private Person lover;
lover
0..1
public Person(String name) {
this.name = name;
lover = null;
Person
}
public fallsInLoveWith(Person p) ...
...
}
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
51
Hand-in-Hand Modeling and Coding (2)
class Person {
private String name;
private Person lover;
lover
0..1
spouse
Person
public Person(String name) {
this.name = name;
lover = null;
0..1
}
public fallsInLoveWith(Person p) ...
...
}
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
52
Hand-in-Hand Modeling and Coding (2)
lover
0..1
spouse
Person
class Person {
private String name;
private Person lover;
private Person spouse;
public Person(String name) {
this.name = name;
lover = null;
spouse = null;
0..1
}
public fallsInLoveWith(Person p) ...
public marries(Person p) ...
...
}
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
53
Hand-in-Hand Modeling and Coding (2)
lover
0..1
spouse
Person
class Person {
private String name;
private Person lover;
private Person spouse;
public Person(String name) {
this.name = name;
lover = null;
spouse = null;
0..1
*
}
friends
public fallsInLoveWith(Person p) ...
public marries(Person p) ...
...
}
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
54
Hand-in-Hand Modeling and Coding (2)
lover
0..1
spouse
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();
}
0..1
*
friends
public fallsInLoveWith(Person p) ...
public marries(Person p) ...
public becomesFriendWith(Person p) ...
...
}
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
55
Example: Telstra Lite
1
*
MMObject
*
Customer
Image
Sound
Video
ACE 2013, Adelaide, AUS
*
Subscription
Transaction
Call
MMS
Payment
SMS
Conversation
Model-Driven Programming Education
56
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
57
Course Progression
Design
Conceptual Model
Specification Model
Analysis
Implementation
Problem/vision
Implementation Model
Reference System
ACE 2013, Adelaide, AUS
Model System
Model-Driven Programming Education
58
Course Progression
Design
Conceptual model
Specification model
Analysis
Implementation
Problem/vision
Implementation model
Problem domain
ACE 2013, Adelaide, AUS
Model
Model-Driven Programming Education
59
Model-Based Progression
Stand-alone class
A
Shape, Turtle, Person, Die, Date, Heater, Account, ...
Simple association and composition
2
A
B
A
2
B
Recursive Association
A
0..1
A
Person (lover and fiancee),
Person (friends)
Animal (parents, brood), ...
*
Association (to another class)
A
0..1
B
A
Implementing an interface
A
*
B
DieCup, ClockDisplay, ...
I
*
B
Car-Person (isOwnedBy),
Track-Playlist (contains)
Comparable and Comparator
Use of Collections.sort(), etc.
60
Faded Guidance and Cognitive Apprenticeship
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
P
*
T
3. A lab session follows where the students interact with,
modify, and extend both examples.
4. A follow-up exercise is provided where the students
extend the Playlist-Track example by adding an Image
class.
5. In the following week we give a mandatory assignment
where the students implement a system of three classes,
say Notebook, Note, and Keyword.
*
I
Nb
*
N
*
K61
Exercise
• Create one or two exercises by concretizing the
following models:
a)
c)
A
*
B
A
*
B
b)
A
ACE 2013, Adelaide, AUS
2
B1
B2
B
Model-Driven Programming Education
62
Motivating and Engaging Problems
• Real-world examples
• Sample projects
– no factorial
– no fibonacci numbers
• Multimedia
– image and sound processing
• Mobile technology
– cell phones
– PDAs
– MP3-players
• Internet technology
– web browser
ACE 2013, Adelaide, AUS
–
–
–
–
–
–
–
–
–
–
–
–
–
–
Model-Driven Programming Education
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
...
63
Assessment (Varying Cover Story)
Track * Playlist
Diagnosis * Person
Luggage * Flight
Plant * Allotment
TextFile * Directory
SideEffect * Medicine
Magazine * Subscriber
Picture * MemoryCard
Card * Deck
TimeSheet * HourlyPaid
Employee * Department
Instrument * Musician
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
64
Principles of Programming Education
Practice consume before produce
Present worked, exemplary examples
Reinforce patterns and conceptual frameworks
...
Allows more interesting things
to be done.
Helps separate spec and impl.
Applies at many levels (code
specification, class libraries,
design patterns, frameworks, ...)
Method
Class
Model
Use
1
1
1
Modify
2
3
4
Create
5
6
7
65
Course Phases
Method use
(4) Programming method: STREAM,
patterns for implementing functionality
(algorithmic patterns).
Class create
(5) Subject specific assignment: Practice
on harder problems.
Class create
(6) Practice: Achieve routine in solving
standard tasks (prep for exam).
Class create
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
Worked examples and faded guidance
Class modify
Cognitive apprenticeship (to reveal process)
(3) Conceptual framework and patterns:
Control structures, data structures
(collections), class relationship, patterns for
implementing structure (association).
Cognitive skill
acquisition and
automation
Method modify
Method create
Increase germane CL (patterns)
(2) Introduction to the basics: Class,
object, state, behaviour, control structures.
Reduce extraneous CL
(1) Getting started: Overview of
fundamental concepts. Learning the
IDEs and other tools.
66
Benefits of MDP
The integration of
conceptual modeling and coding provides
structure, traceability, and a systematic approach to
program development
The integrated approach
motivate and support students
in their understanding and practice of
the programming process
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
67
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
68
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
69
Model-Driven
Programming Education
Workshop @ ACE 2013
Michael E. Caspersen
Department of Computer Science
and Centre for Science Education
Aarhus University, Denmark
mec@cse.au.dk
Structure (for planning only)
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 & McCartney
Stan & Laurel
Alice and Randy Pausch
ACE 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
71
Programs as models
E.W. Dijkstra
It’s not the purpose of our programs
to instruct the computer;
it’s the purpose of the computer
to execute our programs
K. Nygaard
A program execution is regarded as
a physical model system
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
72
Pattern-Based Instruction
Motivation
Patterns capture chunks of programming knowledge and skills.
Reinforces schema creation when cognitive load is “controlled”
(+germane cognitive load).
(Cognitive science and educational psychology)
Origin
Ideas 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
73
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...
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
74
Patterns at Two Levels
Inter-class structure
Standard coding patterns for
the implementation of relations
between classes.
Association pattern
Aggregation pattern
Specialization pattern
Intra-class structure
Class invariants and
techniques for evaluating
these.
Method structure
Algorithmic patterns,
elementary patterns and loop
invariants.
ACE 2013, Adelaide, AUS
Model-Driven Programming Education
Sweep pattern
Search pattern
Divide, solve, and combine
...
75
Download