SlideShare a Scribd company logo
The I in PRIMM
Code comprehension and questioning
Dr Sue Sentance
29th February 2020
@suesentance
CAS London Conference 2020
Objectives of this session
- To briefly outline the PRIMM methodology and point to
some resources
- To introduce the Block Model as a way of thinking about
programming at different levels
- How we can use questioning and targeted tasks to
support comprehension of program code
- To share some potential tasks around code
comprehension that you could use on Monday!
What can cause learners to struggle with
programming tasks?
Challenges faced Possible reasons …
Perception of
programming as hard –
challenges resilience and
self-efficacy
Programs usually don’t work until many iterations have
passed
There is a “hard” myth (or is it a myth)
Belief in geek gene
Use of “adult” teaching approaches
A working program does
not equate to
understanding of
programming concepts
Too much copying of code without understanding
High cognitive load involved in programming
Focus on product rather than process
Students have
misconceptions &
incorrect mental model
Many misconceptions are known but this has not
transferred into teacher training
Teachers have fragile knowledge & misconceptions too
Programming pedagogy & PRIMM
Some examples:
• Pair programming (Williams & Kessler,
2002)
• Worked examples (Morrison,
Margulieux & Guzdial, 2015)
• Peer instruction (Porter et al, 2011)
• Live coding/ modelling (Rubin, 2013)
• Tracing/ reading code (Lister, many)
• Use-modify-create (Lee et al, 2011)
• Stepwise explanations (Wirth, 2001)
In this context, PRIMM is one approach
to use for programming pedagogy
Specifically it is designed to:
1) Help teachers structure lessons
2) Reflect on the teaching process
3) Cater for varying needs
The PRIMM approach
• Predict – given a working program, talk about it in
pairs or groups. What do you think it will do?
• Run – run it and test your prediction
• Investigate – get into the nitty gritty. What does
each line of code mean? Lots of activities to try
here: trace, annotate, explain, talk about,
identify parts, etc….
• Modify – edit the program to make it do different
things
• Make – design a new program that uses the same
nitty gritty but that solves a new problem
Look at this Python (turtle) code
Discuss with the person next to you
Draw the output
What discussions did you have?
Did you help each other?
What did you learn?
An activity for you – you will need a piece of paper and a companion
Now imagine you could run the program
This is what would actually be output
Did you get it right?
If not, what is different about your answer?
PRIMM Examples
Predict
Run
Investigate
Modify
Make
Lesson 3
PRIMM Examples
Predict
Run
Investigate
Modify
Make
Keep starter programs
on a shared drive
Students should
download, check what
they do and compare
with prediction
PRIMM Examples
Predict
Run
Investigate
Modify
Make
Ask different types of questions
PRIMM Examples
Predict
Run
Investigate
Modify
Make
PRIMM Examples
Predict
Run
Investigate
Modify
Make
PRIMM Examples
Predict
Run
Investigate
Modify
Make
Improve the pizza program so that it doesn’t print out
“and X” at the end. You will have to add an “if”
statement to do this.
Modify the program to have a conversation with
somebody about sport. An example is given below but
you can add your own questions.
Change your triangle function so that it uses a for loop
Write a function pentagon() to create a pentagon (5
sides) with sides length 200
Write a function hexagon() to create a blue hexagon (6
sides) with sides length 50
PRIMM Examples
Predict
Run
Investigate
Modify
Make
Focusing in on Investigate
What are good questions to ask?
Here are two programs (they do the same thing – just choose
the language you prefer!)
What questions might you ask learners to help you gauge their
understanding?
Activity 1: Asking questions
Two versions of the same program
In pairs or threes, think about some good
“Investigate” questions you could ask pupils
to see if they understood the code – and to
prepare them to write something similar
Feedback
Why focus on code comprehension?
• Being able to read and understand code greatly increases
your ability to write code (proven by research)
• Talking about the program means you need the words to
label the various parts – so improves program terminology –
the teacher can help here
• The goal of program comprehension is to allow the
beginner programmer to construct their own mental model.
But how do we know if we are asking the right questions?
And if the pupils can’t answer what does that tell us?
Enter …. The Block Model
What if we could classify tasks and questions?
What is … ?
How would
you …?
Can you spot
the …?
Show me a
… ?
What does …
do?
Granularity of
piece of program
code
Structure ---> Function of program
(M) Macro structure Understanding the
overall structure of the
program text
Understanding the
algorithm underlying a
program
Understanding the
goal/purpose of the
program in the current
context
(R) Relationships Relationships between
blocks
Sequence of function
calls, object sequence
diagrams
Understanding how sub
goals are related to goals
(B) Blocks Regions of interest that
build a unit (syntactically
or semantically)
Operation of a block or
function.
Understanding of the
function of a block of
code.
(A) Atoms Language elements Operation of a
statement.
Function of a statement.
(T) Text Surface (P) Program Execution (F) Function
Architecture/ Structure Relevance /Intention
The Block Model
(M) Macro structure
(R) Relationships
(B) Blocks
(A) Atoms Identify the keywords in
a piece of code
(T) Text Surface (P) Program Execution (F) Function
Architecture/ Structure Relevance /Intention
The Block Model
When a student really understands
the program code they should be
able to answer questions in every
area of the Block Model
(M) Macro structure What does this program
do?
(R) Relationships
(B) Blocks
(A) Atoms Identify the keywords in
a piece of code
(T) Text Surface (P) Program Execution (F) Function
Architecture/ Structure Relevance /Intention
The Block Model
When a student really understands
the program code they should be
able to answer questions in every
area of the Block Model
Activity 2: Types of questions/tasks
In pairs or threes ….
Look at the list of possible tasks/questions around code
comprehension
Where might they fit on the Block Model?
Example
(M) Macro structure Annotate the whole
program showing where
functions are called and
defined.
What set of inputs
could be used to check
all routes/flows through
the program
Summarise what the
program does
(R) Relationships Identify the scope of a
variable
Identify which branch
of an if statement will
never be executed
Identify two blocks of
code which will produce
the same outputs
(B) Blocks Draw a block around an
if statement
Solve a Parson’s
Problem
Give an appropriate
name to a block of code
or function
(A) Atoms List all the integer
variables
Trace a value through
the program code
Identify the purpose of a
single statement
Answer (T) Text Surface (P) Program Execution (F) Function
Architecture/ Structure Relevance /Intention
The Block Model
(M) Macro structure
✓ ✓ ✓
(R) Relationships
✓ ✓ ✓
(B) Blocks
✓ ✓ ✓
(A) Atoms
✓ ✓ ✓
Answer (T) Text Surface (P) Program Execution (F) Function
Architecture/ Structure Relevance /Intention
The Block Model
Carla
Mia
(M) Macro structure
X ✓ ✓
(R) Relationships
✓ ✓ ✓
(B) Blocks
✓ X X
(A) Atoms
✓ X ✓
Answer (T) Text Surface (P) Program Execution (F) Function
Architecture/ Structure Relevance /Intention
The Block Model
Carla
“Novice programmers’ early
comprehension models can be
characterized by a pattern of “holey
knowledge”(i.e. an incomplete
patchwork of fabric, with empty
cells and missing stuffing)” (Schulte
et al, 2010)
Why is it important to ask different types of questions
about the code?
The Holey
Quilt
(gaps in
knowledge)
“Novice programmers’ early
comprehension models can be
characterized by a pattern of “holey
knowledge”(i.e. an incomplete
patchwork of fabric, with empty
cells and missing stuffing)” (Schulte
et al, 2010)
The programming “mental model”
Includes:
- Elements and structure of the program
- Execution behaviour of the program
- Purpose of the whole program
- Purpose of individual blocks
How is the mental model developed? One view ….
Social plane Cognitive plane
(Vygotsky)
Activity 3: Revisiting activity 1
Now look back at the program we looked at earlier
You thought of some questions
Where are these in the Block Model?
Discuss ….
Which tasks and questions are easier to answer than others?
How to progress through different
questions and tasks?
(M) Macro structure Understanding the
overall structure of the
program text
Understanding the
algorithm underlying a
program
Understanding the
goal/purpose of the
program in the current
context
(R) Relationships Relationships between
blocks
Sequence of function
calls, object sequence
diagrams
Understanding how sub
goals are related to goals
(B) Blocks Regions of interest that
build a unit (syntactically
or semantically)
Operation of a block or
function.
Understanding of the
function of a block of
code.
(A) Atoms Language elements Operation of a
statement.
Function of a statement.
(T) Text Surface (P) Program Execution (F) Function
Architecture/ Structure Relevance /Intention
The Block Model
What about progression
through the types of
tasks? ?
What does the program do?
“One interesting observation is that students often have
difficulties explaining the purpose of the whole program (MF),
and if asked to describe the code goal, they explain the
execution of the program (P) and often step-by-step.” (Izu et
al, 2020).
In PRIMM we start with predicting the purpose of a small block
of code. This serves as a reminder that this is not easy for
students, and so simple, short extracts of code should be used.
The goal of predict is to get students used to thinking about
why programs are there and to focus on function first.
Try it out with your classes
Try to ask different questions about programs in your class
Which types of question are most difficult/ easy?
Where is the progression?
Where can we uncover misconceptions?
Try out in your class. Do share any insights with me.
This work is ongoing research. More details will appear at
http://primming.wordpress.com
PRIMM Resources
http://primming.wordpress.com
Materials here that were
used for the two
research studies – and in
time we hope to upload
teachers’ contributions
from their own PRIMM
resources
If you have PRIMM
resources please share
with me!
Summary
- A brief introduction to PRIMM
- The importance of understanding program code
- The Block Model for code comprehension
- Some tasks and questions to use in class
- Remember the holey quilt!
Further reading (if you like depth)
Izu et al (2019). Fostering Program Comprehension in Novice Programmers-Learning Activities and Learning
Trajectories. In Proceedings of the Working Group Reports on Innovation and Technology in Computer Science
Education (pp. 27-52).
Sentance, S., Waite, J., & Kallia, M. (2019). Teaching computer programming with PRIMM: a sociocultural
perspective. Computer Science Education, 29(2-3), 136-176.
Further browsing
http://primming.wordpress.com
Thanks for participating
Contact me at
sue@raspberrypi.org or
sue.sentance@kcl.ac.uk
@suesentance

More Related Content

PPT
cold fusion ppt
PDF
Teacher toolkit Pycon UK Sept 2018
PDF
Recent developments in CS education research Jul 18
PPTX
Teaching of computer programming
PDF
From programming to software engineering: ICSE keynote slides available
PDF
How not to fail at programming education
PDF
Primm and Classroom Talk Sue Sentance Nov 2020 pdf
PPT
7-CodingAndUT.ppt
cold fusion ppt
Teacher toolkit Pycon UK Sept 2018
Recent developments in CS education research Jul 18
Teaching of computer programming
From programming to software engineering: ICSE keynote slides available
How not to fail at programming education
Primm and Classroom Talk Sue Sentance Nov 2020 pdf
7-CodingAndUT.ppt

Similar to The I in PRIMM - Code Comprehension and Questioning (20)

PDF
Rubric-based Assessment of Programming Thinking Skills and Comparative Evalua...
PPTX
2.3.tarek
PPTX
VII Jornadas eMadrid "Education in exponential times". "Learning and teaching...
PPTX
Solid OOPS
DOCX
Coding io1-materials for students-group2
PDF
1. Introduction to Programming concepts LICSTA.pdf
PPTX
OOP, API Design and MVP
PDF
Object Oriented Programming - Chapter 1 - Introduction.pdf
PPTX
INTRODUCTION TO CODING-CLASS VI LEVEL-DESCRIPTION ABOUT SYNTAX LANGUAGE
PPTX
classVI_Coding_Teacher_Presentation.pptx
PPTX
classVI_Coding_Teacher_Presentation.pptx
PPTX
Learn to code in 15 minutes
PDF
Botbeans CISTI 2011
PDF
structured programming Introduction to c fundamentals
DOCX
Coding wp2-comparative study-si(1)
PDF
Artigo Educon2012
PPT
Savitch Ch 01
PPT
Code generator
PDF
Iccie2012 siti rosminah
PPT
computer programming introduction ppt.ppt
Rubric-based Assessment of Programming Thinking Skills and Comparative Evalua...
2.3.tarek
VII Jornadas eMadrid "Education in exponential times". "Learning and teaching...
Solid OOPS
Coding io1-materials for students-group2
1. Introduction to Programming concepts LICSTA.pdf
OOP, API Design and MVP
Object Oriented Programming - Chapter 1 - Introduction.pdf
INTRODUCTION TO CODING-CLASS VI LEVEL-DESCRIPTION ABOUT SYNTAX LANGUAGE
classVI_Coding_Teacher_Presentation.pptx
classVI_Coding_Teacher_Presentation.pptx
Learn to code in 15 minutes
Botbeans CISTI 2011
structured programming Introduction to c fundamentals
Coding wp2-comparative study-si(1)
Artigo Educon2012
Savitch Ch 01
Code generator
Iccie2012 siti rosminah
computer programming introduction ppt.ppt
Ad

Recently uploaded (20)

PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Lesson notes of climatology university.
PPTX
Cell Structure & Organelles in detailed.
PDF
Classroom Observation Tools for Teachers
PDF
Sports Quiz easy sports quiz sports quiz
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Pre independence Education in Inndia.pdf
PPTX
Pharma ospi slides which help in ospi learning
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
master seminar digital applications in india
PDF
Insiders guide to clinical Medicine.pdf
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Microbial disease of the cardiovascular and lymphatic systems
Lesson notes of climatology university.
Cell Structure & Organelles in detailed.
Classroom Observation Tools for Teachers
Sports Quiz easy sports quiz sports quiz
Final Presentation General Medicine 03-08-2024.pptx
human mycosis Human fungal infections are called human mycosis..pptx
VCE English Exam - Section C Student Revision Booklet
Computing-Curriculum for Schools in Ghana
Renaissance Architecture: A Journey from Faith to Humanism
Pre independence Education in Inndia.pdf
Pharma ospi slides which help in ospi learning
Supply Chain Operations Speaking Notes -ICLT Program
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
O7-L3 Supply Chain Operations - ICLT Program
TR - Agricultural Crops Production NC III.pdf
master seminar digital applications in india
Insiders guide to clinical Medicine.pdf
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Ad

The I in PRIMM - Code Comprehension and Questioning

  • 1. The I in PRIMM Code comprehension and questioning Dr Sue Sentance 29th February 2020 @suesentance CAS London Conference 2020
  • 2. Objectives of this session - To briefly outline the PRIMM methodology and point to some resources - To introduce the Block Model as a way of thinking about programming at different levels - How we can use questioning and targeted tasks to support comprehension of program code - To share some potential tasks around code comprehension that you could use on Monday!
  • 3. What can cause learners to struggle with programming tasks? Challenges faced Possible reasons … Perception of programming as hard – challenges resilience and self-efficacy Programs usually don’t work until many iterations have passed There is a “hard” myth (or is it a myth) Belief in geek gene Use of “adult” teaching approaches A working program does not equate to understanding of programming concepts Too much copying of code without understanding High cognitive load involved in programming Focus on product rather than process Students have misconceptions & incorrect mental model Many misconceptions are known but this has not transferred into teacher training Teachers have fragile knowledge & misconceptions too
  • 4. Programming pedagogy & PRIMM Some examples: • Pair programming (Williams & Kessler, 2002) • Worked examples (Morrison, Margulieux & Guzdial, 2015) • Peer instruction (Porter et al, 2011) • Live coding/ modelling (Rubin, 2013) • Tracing/ reading code (Lister, many) • Use-modify-create (Lee et al, 2011) • Stepwise explanations (Wirth, 2001) In this context, PRIMM is one approach to use for programming pedagogy Specifically it is designed to: 1) Help teachers structure lessons 2) Reflect on the teaching process 3) Cater for varying needs
  • 5. The PRIMM approach • Predict – given a working program, talk about it in pairs or groups. What do you think it will do? • Run – run it and test your prediction • Investigate – get into the nitty gritty. What does each line of code mean? Lots of activities to try here: trace, annotate, explain, talk about, identify parts, etc…. • Modify – edit the program to make it do different things • Make – design a new program that uses the same nitty gritty but that solves a new problem
  • 6. Look at this Python (turtle) code Discuss with the person next to you Draw the output What discussions did you have? Did you help each other? What did you learn? An activity for you – you will need a piece of paper and a companion
  • 7. Now imagine you could run the program This is what would actually be output Did you get it right? If not, what is different about your answer?
  • 9. PRIMM Examples Predict Run Investigate Modify Make Keep starter programs on a shared drive Students should download, check what they do and compare with prediction
  • 13. PRIMM Examples Predict Run Investigate Modify Make Improve the pizza program so that it doesn’t print out “and X” at the end. You will have to add an “if” statement to do this. Modify the program to have a conversation with somebody about sport. An example is given below but you can add your own questions. Change your triangle function so that it uses a for loop Write a function pentagon() to create a pentagon (5 sides) with sides length 200 Write a function hexagon() to create a blue hexagon (6 sides) with sides length 50
  • 15. Focusing in on Investigate What are good questions to ask? Here are two programs (they do the same thing – just choose the language you prefer!) What questions might you ask learners to help you gauge their understanding?
  • 16. Activity 1: Asking questions Two versions of the same program In pairs or threes, think about some good “Investigate” questions you could ask pupils to see if they understood the code – and to prepare them to write something similar
  • 18. Why focus on code comprehension? • Being able to read and understand code greatly increases your ability to write code (proven by research) • Talking about the program means you need the words to label the various parts – so improves program terminology – the teacher can help here • The goal of program comprehension is to allow the beginner programmer to construct their own mental model. But how do we know if we are asking the right questions? And if the pupils can’t answer what does that tell us?
  • 19. Enter …. The Block Model
  • 20. What if we could classify tasks and questions? What is … ? How would you …? Can you spot the …? Show me a … ? What does … do? Granularity of piece of program code Structure ---> Function of program
  • 21. (M) Macro structure Understanding the overall structure of the program text Understanding the algorithm underlying a program Understanding the goal/purpose of the program in the current context (R) Relationships Relationships between blocks Sequence of function calls, object sequence diagrams Understanding how sub goals are related to goals (B) Blocks Regions of interest that build a unit (syntactically or semantically) Operation of a block or function. Understanding of the function of a block of code. (A) Atoms Language elements Operation of a statement. Function of a statement. (T) Text Surface (P) Program Execution (F) Function Architecture/ Structure Relevance /Intention The Block Model
  • 22. (M) Macro structure (R) Relationships (B) Blocks (A) Atoms Identify the keywords in a piece of code (T) Text Surface (P) Program Execution (F) Function Architecture/ Structure Relevance /Intention The Block Model When a student really understands the program code they should be able to answer questions in every area of the Block Model
  • 23. (M) Macro structure What does this program do? (R) Relationships (B) Blocks (A) Atoms Identify the keywords in a piece of code (T) Text Surface (P) Program Execution (F) Function Architecture/ Structure Relevance /Intention The Block Model When a student really understands the program code they should be able to answer questions in every area of the Block Model
  • 24. Activity 2: Types of questions/tasks In pairs or threes …. Look at the list of possible tasks/questions around code comprehension Where might they fit on the Block Model? Example
  • 25. (M) Macro structure Annotate the whole program showing where functions are called and defined. What set of inputs could be used to check all routes/flows through the program Summarise what the program does (R) Relationships Identify the scope of a variable Identify which branch of an if statement will never be executed Identify two blocks of code which will produce the same outputs (B) Blocks Draw a block around an if statement Solve a Parson’s Problem Give an appropriate name to a block of code or function (A) Atoms List all the integer variables Trace a value through the program code Identify the purpose of a single statement Answer (T) Text Surface (P) Program Execution (F) Function Architecture/ Structure Relevance /Intention The Block Model
  • 26. (M) Macro structure ✓ ✓ ✓ (R) Relationships ✓ ✓ ✓ (B) Blocks ✓ ✓ ✓ (A) Atoms ✓ ✓ ✓ Answer (T) Text Surface (P) Program Execution (F) Function Architecture/ Structure Relevance /Intention The Block Model Carla Mia
  • 27. (M) Macro structure X ✓ ✓ (R) Relationships ✓ ✓ ✓ (B) Blocks ✓ X X (A) Atoms ✓ X ✓ Answer (T) Text Surface (P) Program Execution (F) Function Architecture/ Structure Relevance /Intention The Block Model Carla “Novice programmers’ early comprehension models can be characterized by a pattern of “holey knowledge”(i.e. an incomplete patchwork of fabric, with empty cells and missing stuffing)” (Schulte et al, 2010)
  • 28. Why is it important to ask different types of questions about the code? The Holey Quilt (gaps in knowledge) “Novice programmers’ early comprehension models can be characterized by a pattern of “holey knowledge”(i.e. an incomplete patchwork of fabric, with empty cells and missing stuffing)” (Schulte et al, 2010)
  • 29. The programming “mental model” Includes: - Elements and structure of the program - Execution behaviour of the program - Purpose of the whole program - Purpose of individual blocks How is the mental model developed? One view …. Social plane Cognitive plane (Vygotsky)
  • 30. Activity 3: Revisiting activity 1 Now look back at the program we looked at earlier You thought of some questions Where are these in the Block Model? Discuss …. Which tasks and questions are easier to answer than others?
  • 31. How to progress through different questions and tasks?
  • 32. (M) Macro structure Understanding the overall structure of the program text Understanding the algorithm underlying a program Understanding the goal/purpose of the program in the current context (R) Relationships Relationships between blocks Sequence of function calls, object sequence diagrams Understanding how sub goals are related to goals (B) Blocks Regions of interest that build a unit (syntactically or semantically) Operation of a block or function. Understanding of the function of a block of code. (A) Atoms Language elements Operation of a statement. Function of a statement. (T) Text Surface (P) Program Execution (F) Function Architecture/ Structure Relevance /Intention The Block Model What about progression through the types of tasks? ?
  • 33. What does the program do? “One interesting observation is that students often have difficulties explaining the purpose of the whole program (MF), and if asked to describe the code goal, they explain the execution of the program (P) and often step-by-step.” (Izu et al, 2020). In PRIMM we start with predicting the purpose of a small block of code. This serves as a reminder that this is not easy for students, and so simple, short extracts of code should be used. The goal of predict is to get students used to thinking about why programs are there and to focus on function first.
  • 34. Try it out with your classes Try to ask different questions about programs in your class Which types of question are most difficult/ easy? Where is the progression? Where can we uncover misconceptions? Try out in your class. Do share any insights with me. This work is ongoing research. More details will appear at http://primming.wordpress.com
  • 35. PRIMM Resources http://primming.wordpress.com Materials here that were used for the two research studies – and in time we hope to upload teachers’ contributions from their own PRIMM resources If you have PRIMM resources please share with me!
  • 36. Summary - A brief introduction to PRIMM - The importance of understanding program code - The Block Model for code comprehension - Some tasks and questions to use in class - Remember the holey quilt! Further reading (if you like depth) Izu et al (2019). Fostering Program Comprehension in Novice Programmers-Learning Activities and Learning Trajectories. In Proceedings of the Working Group Reports on Innovation and Technology in Computer Science Education (pp. 27-52). Sentance, S., Waite, J., & Kallia, M. (2019). Teaching computer programming with PRIMM: a sociocultural perspective. Computer Science Education, 29(2-3), 136-176. Further browsing http://primming.wordpress.com Thanks for participating Contact me at sue@raspberrypi.org or sue.sentance@kcl.ac.uk @suesentance