Presentation is loading. Please wait.

Presentation is loading. Please wait.

Teaching and learning programming DECEMBER 18 TH SUE SENTANCE 1.

Similar presentations


Presentation on theme: "Teaching and learning programming DECEMBER 18 TH SUE SENTANCE 1."— Presentation transcript:

1 Teaching and learning programming DECEMBER 18 TH SUE SENTANCE 1

2 Objectives of today We will look at a variety of strategies and approaches to the learning of programming, and the theory behind these.  Working with visual vs text-based environments  Tinkering vs planning when learning programming  Peer Instruction  Visualisation mechanism (taken from PLAN C materials)  Pair programming to support learning of programming Other strategies  Program functionality  Debugging exercises  Commenting code 2

3 Plan of the day TimeTopic 10:00Visual vs text-based programming 10:45Exploratory learning – pros and cons 11:30Peer instruction 12:30Lunch 1:30Tracing – TRACS methodology 2:30Pair programming 3:00End of term celebration 3

4 Topic 1: Visual and Text-based programming What’s the difference? How to move between one and the other? 4

5 Task: Visual vs Text-based Beginners Write a program to draw a triangle in a)Scratch and b)Python Advanced Write a program to draw any shape between 3 and 8 sides when the user inputs the number of sides in a)Scratch and b)Python 5

6 Topic 1: Scratch -> Python 6

7 Functions in Scratch and Python In this example, the user enters the number of sides and the shape is drawn. The program works out 360/Number of sides and this gives the number of degrees to turn 7

8 Topic 1: Scratch -> Python 8

9 Loops in Scratch and Python repeat … until repeat X times forever while for = = 9

10 Calculations in Scratch and Python 10

11 Program in Scratch and Python 11

12 Scratch example simulation Simulation of the solar system in ScratchSimulation of the solar system in Scratch

13 Visual and text-based programming Summary  Can be used for different purposes (all programming languages are better at some things than others) so keep using Scratch (or other block-based language) for tasks that suit it  Learning more than one language helps you to see that algorithms and programming are not just to do with one language environment  Solving the same problem in two languages helps demonstrate that the problem solving is the same and that only the syntax is different  Solving the same problem in two languages helps students to learn the second language because the new knowledge builds on what is familiar, known and understood. 13

14 Reading Mark Dorling and Dave White. 2015. Scratch: A Way to Logo and Python. In Proceedings of the 46th ACM Technical Symposium on Computer Science Education (SIGCSE '15). 14

15 Topic 2: Tinkering vs planning 15

16 Constructionism – Seymour Papert  Constructionism - Learning theory that supports the importance of doing  Proposed by Seymour Paper, colleague of Piaget, “father of educational technology”  Children learn by building a personal world-view piece by piece, adding onto what they already know and can do  Making things in the real world cements childrens’ knowledge  Learning happens as a product of experience  Learning by exploring – see the Papert youtube video herePapert youtube video here 16

17 Topic 2: Tinkering vs planning Reading: Habits of Programming in Scratch by Orni Meerbaum-Salant et al Summary  Using Scratch encourages self-directed learning  Children try out commands and see what they do (exploratory)  This can encourage “bad habits” for later programming, for example bottom-up programming and “extremely fine-grained programming” (too much decomposition resulting in hundreds of scripts doing very specific things)  In CT terms – lack of generalisation and lack of abstraction 17

18 Planning vs prototyping Didactic approach vs exploratory learning 18 We need both but in what proportions ….

19 Flowchart for this program Start Name = “Stop?” Name = “” Input name Output thanks NO YES 19

20 Pseudocode for this program set name to “” (actually not needed with a repeat) repeat send “Type in a name” to display receive name from input(keyboard) until name = “Stop” send “Thanks – no more asking” to display One option 20

21 Breakout question 1 “To what extent should we promote planning of algorithms in advance before programming and to what extent should we encourage exploring and tinkering!” 21

22 Topic 3: Peer instruction 22

23 Support for students learning programming Developing programming skills Problems of prior pupil experiences of programming Some strategies: Peer Instruction Program functionality Visualisation mechanism (taken from PLAN C materials) Debugging exercises Commenting code Pair programming 23

24 Developing programming skills Writing programs requires: Understanding of algorithm design and development Knowledge of programming constructs (selection, loops, etc) Translation of concepts into a particular programming language Debugging skills Knowledge of the programming language environment What about reading and understanding programs first? 24

25 Problems of prior pupil experience Intuition Reliance on the other persons experience and ability to deal with ambiguity. Precision doesn’t really matter Reliance on copying other examples that might be similar. “The computer doesn’t like me and is being awkward” Understanding Realisation that a computer has no prior experience and struggles with ambiguity. Precision is crucial Choosing features based on what you want the computer to do. “I haven’t correctly described the process” 25

26 Peer Instruction – testing for faulty mental models Technique originally developed in Physics by Eric Mazur at Harvard university Way of assessing whether novices really understand concepts requiring a precise understanding Based on carefully designed multiple choice questions with structured discussion and voting 26

27 Peer instruction in a school context Before Pupils have worked with the concepts in class or at home. Individual Pupils read the question and choose an answer Vote takes place Group Pupils discuss what answer they chose and why Vote takes place Class Teacher facilitated discussion Vote takes place Correct Answer Teacher reveals the correct answer Teacher explains why it’s correct 27

28 The variables angel and egyptian contain 1.7 and 2.0 respectively, which represent their height. What is written out…? IF angel > egyptian THEN SEND "Egyptian is taller" TO DISPLAY ELSE SEND "Angel is taller" TO DISPLAY END IF A.Egyptian is taller B.Angel is taller C.Egyptian is taller Angel is taller D. 28

29 Consider what this code does when metalColour is blue, red, or green… IF metalColour == "blue" THEN SEND "Cold" TO DISPLAY ELSE IF metalColour == "red" THEN SEND "Hot!" TO DISPLAY ELSE SEND "Try again!" TO DISPLAY END IF Which options are true? A.When metalColour is blue, Cold displayed B.When metalColour is red, Hot! displayed C.When metalColour is blue, both Cold AND Try again! displayed D.When metalColour is green, nothing happens 29

30 How many times is Hello written out? SET i TO 0 WHILE i <= 5 DO SEND "Hello" TO DISPLAY SET i TO i + 1 END WHILE A: 4 B: 5 C: 6 D: 7 E: 30

31 How many times is Hello written out? SET i TO 10 REPEAT i TIMES SET i TO i – 2 SEND "Hello" TO DISPLAY END REPEAT A: 10 B: 8 C: 6 D: 4 31

32 Peer instruction vs teacher explanation: research findings Statistically significant effect Twice as effective as a good teacher explanation Successfully used in Physics, Maths and Computing Science Develops better sense of self efficacy particular amongst girls 32

33 Identifying and describing mechanisms The importance of understanding computer science language Identifying mechanisms in a simple piece of code We will demonstrate an activity involving identifying and describing mechanisms 33

34 Readings on peer instruction – a small section (there are many) J. D. Chase and Edward G. Okie. 2000. Combining cooperative learning and peer instruction in introductory computer science. In Proceedings of the thirty-first SIGCSE technical symposium on Computer science education (SIGCSE '00) Beth Simon, Sarah Esper, Leo Porter, and Quintin Cutts. 2013. Student experience in a student-centered peer instruction classroom. In Proceedings of the ninth annual international ACM conference on International computing education research (ICER '13). Leo Porter, Mark Guzdial, Charlie McDowell, and Beth Simon. 2013. Success in introductory programming: what works?. Commun. ACM 56, 8 (August 2013), 34-36 34

35 Topic 4: Visualisation mechanisms 35

36 Key Challenges Code writing before code comprehension makes this more difficult for novices Need to understand the hidden mechanisms Computational constructs are tightly linked 36

37 The Block model (Schulte, 2008) 37

38 SET password TO “” SET attempts TO 0 REPEAT SEND “Please enter the correct password” TO DISPLAY RECEIVE password FROM (STRING) KEYBOARD SET attempts TO attempts + 1 UNTIL password = “12345” OR attempts > 3 Identifying program functionality What will this code do? 38

39 MECHANISM VISUALISER EXAMPLE For this activity you will need a copy of the example programs and some pens to write with. The first example we will do together. The second one you will do on your own 39

40 Variables Table SET total TO 0 RECEIVE nextInput FROM (INTEGER) KEYBOARD WHILE nextInput != -1 DO SET total TO total + nextInput RECEIVE nextInput FROM (INTEGER) KEYBOARD END WHILE SEND total TO DISPLAY Step 1- Draw a red rectangle around all expressions Expression evaluator

41 SET total TO 0 RECEIVE nextInput FROM (INTEGER) KEYBOARD WHILE nextInput != -1 DO SET total TO total + nextInput RECEIVE nextInput FROM (INTEGER) KEYBOARD END WHILE SEND total TO DISPLAY Step 1- Draw a rectangle around all expressions Variables Table Expression evaluator

42 SET total TO 0 RECEIVE nextInput FROM (INTEGER) KEYBOARD WHILE nextInput != -1 DO SET total TO total + nextInput RECEIVE nextInput FROM (INTEGER) KEYBOARD END WHILE SEND total TO DISPLAY Variables Table Expression evaluator Step 2- Draw in the flow of control as arrows

43 SET total TO 0 RECEIVE nextInput FROM (INTEGER) KEYBOARD WHILE nextInput != -1 DO SET total TO total + nextInput RECEIVE nextInput FROM (INTEGER) KEYBOARD END WHILE SEND total TO DISPLAY Step 2- Draw in the flow of control as arrows T F Variables Table Expression evaluator

44 SET total TO 0 RECEIVE nextInput FROM (INTEGER) KEYBOARD WHILE nextInput != -1 DO SET total TO total + nextInput RECEIVE nextInput FROM (INTEGER) KEYBOARD END WHILE SEND total TO DISPLAY Step 3- Hand execute the program with inputs 20, 7, -1 T F Variables Table Expression evaluator

45 Total 1. 0 Variables Table SET total TO 0 RECEIVE nextInput FROM (INTEGER) KEYBOARD WHILE nextInput != -1 DO SET total TO total + nextInput RECEIVE nextInput FROM (INTEGER) KEYBOARD END WHILE SEND total TO DISPLAY Step 3- Hand execute the program with inputs 20, 7, -1 T F 1 Expression evaluator

46 TotalnextInput 1. 02. 20 Variables Table SET total TO 0 RECEIVE nextInput FROM (INTEGER) KEYBOARD WHILE nextInput != -1 DO SET total TO total + nextInput RECEIVE nextInput FROM (INTEGER) KEYBOARD END WHILE SEND total TO DISPLAY Step 3- Hand execute the program with inputs 20, 7, -1 T F 1. 2. Expression evaluator

47 TotalnextInput 1. 02. 20 Variables Table SET total TO 0 RECEIVE nextInput FROM (INTEGER) KEYBOARD WHILE nextInput != -1 DO SET total TO total + nextInput RECEIVE nextInput FROM (INTEGER) KEYBOARD END WHILE SEND total TO DISPLAY Step 3- Hand execute the program with inputs 20, 7, -1 T F 1. 2. 3. nextInput !- -1 20 != -1 True Expression evaluator (3)

48 TotalnextInput 1. 02. 20 4. 20 3.nextInput !- -1 20 != -1 True 4.total + nextInput 0 + 20 20 Variables Table Expression evaluator SET total TO 0 RECEIVE nextInput FROM (INTEGER) KEYBOARD WHILE nextInput != -1 DO SET total TO total + nextInput RECEIVE nextInput FROM (INTEGER) KEYBOARD END WHILE SEND total TO DISPLAY Step 3- Hand execute the program with inputs 20, 7, -1 T F 1. 2. 3. 4. (3) (4)

49 TotalnextInput 1. 02. 20 4. 205. 7 3.nextInput !- -1 20 != -1 True 4.total + nextInput 0 + 20 20 Variables Table Expression evaluator SET total TO 0 RECEIVE nextInput FROM (INTEGER) KEYBOARD WHILE nextInput != -1 DO SET total TO total + nextInput RECEIVE nextInput FROM (INTEGER) KEYBOARD END WHILE SEND total TO DISPLAY Step 3- Hand execute the program with inputs 20, 7, -1 T F 1. 2. 3. 4. 5. (3) (4)

50 TotalnextInput 1. 02. 20 4. 205. 7 3.nextInput !- -1 20 != -1 True 4.total + nextInput 0 + 20 20 6.nextInput != -1 7 != -1 True Variables Table Expression evaluator SET total TO 0 RECEIVE nextInput FROM (INTEGER) KEYBOARD WHILE nextInput != -1 DO SET total TO total + nextInput RECEIVE nextInput FROM (INTEGER) KEYBOARD END WHILE SEND total TO DISPLAY Step 3- Hand execute the program with inputs 20, 7, -1 T F 1. 2. 3. 4. 5. 6. (3) (4) (6) (4)

51 TotalnextInput 1. 02. 20 4. 205. 7 7. 27 3.nextInput !- -1 20 != -1 True 4.total + nextInput 0 + 20 20 6.nextInput != -1 7 != -1 True 7.total + nextInput 20 + 7 27 Variables Table Expression evaluator SET total TO 0 RECEIVE nextInput FROM (INTEGER) KEYBOARD WHILE nextInput != -1 DO SET total TO total + nextInput RECEIVE nextInput FROM (INTEGER) KEYBOARD END WHILE SEND total TO DISPLAY Step 3- Hand execute the program with inputs 20, 7, -1 T F 1. 2. 3. 4. 7. 5. 6. (3) (4) (6) (7) (4) (7)

52 totalnextInput 1. 02. 20 4. 205. 7 7. 278. -1 3.nextInput !- -1 20 != -1 True 4.total + nextInput 0 + 20 20 6.nextInput != -1 7 != -1 True 7.total + nextInput 20 + 7 27 Variables Table Expression evaluator SET total TO 0 RECEIVE nextInput FROM (INTEGER) KEYBOARD WHILE nextInput != -1 DO SET total TO total + nextInput RECEIVE nextInput FROM (INTEGER) KEYBOARD END WHILE SEND total TO DISPLAY Step 3- Hand execute the program with inputs 20, 7, -1 T F 1. 2. 3. 4. 7. 5. 8. 6. (3) (4) (6) (7) (4) (7)

53 totalnextInput 1. 02. 20 4. 205. 7 7. 278. -1 3.nextInput !- -1 20 != -1 True 4.total + nextInput 0 + 20 20 6.nextInput != -1 7 != -1 True 7.total + nextInput 20 + 7 27 9.nextInput != -1 -1 != -1 False Variables Table Expression evaluator SET total TO 0 RECEIVE nextInput FROM (INTEGER) KEYBOARD WHILE nextInput != -1 DO SET total TO total + nextInput RECEIVE nextInput FROM (INTEGER) KEYBOARD END WHILE SEND total TO DISPLAY Step 3- Hand execute the program with inputs 20, 7, -1 T F 1. 2. 3. 4. 7. 5. 8. 6. 9. (3) (4) (6) (7) (4) (7) (9)

54 totalnextInput 1. 02. 20 4. 205. 7 7. 278. -1 3.nextInput !- -1 20 != -1 True 4.total + nextInput 0 + 20 20 6.nextInput != -1 7 != -1 True 7.total + nextInput 20 + 7 27 9.nextInput != -1 -1 != -1 False Variables Table Expression evaluator SET total TO 0 RECEIVE nextInput FROM (INTEGER) KEYBOARD WHILE nextInput != -1 DO SET total TO total + nextInput RECEIVE nextInput FROM (INTEGER) KEYBOARD END WHILE SEND total TO DISPLAY Step 3- Hand execute the program with inputs 20, 7, -1 T F 1. 2. 3. 4. 7. 5. 8. 6. 9. (3) (4) (6) (7) (4) (7) (9) 10.

55 Next (or for homework – depending on time) Identify all of the expressions by drawing a box around them Identify the control flow by drawing arrows showing what the next instruction will be Hand execute the program making sure to evaluate complicated expressions and create and update variables 55

56 SET found TO FALSE SET numList TO [8,9,13,4] RECEIVE searchKey FROM (INTEGER) KEYBOARD SET pos TO 0 WHILE found  TRUE AND pos < length (numList) DO IF numList [ pos ] = searchKey THEN SET found TO TRUE ELSE SET pos TO pos + 1 END IF END WHILE Array Variables Table Expression evaluator Hand execute program with 13 as input for searchKey

57 SET found TO FALSE SET numList TO [8,9,13,4] RECEIVE searchKey FROM (INTEGER) KEYBOARD SET pos TO 0 WHILE found  TRUE AND pos < length (numList) DO IF numList [ pos ] = searchKey THEN SET found TO TRUE ELSE SET pos TO pos + 1 END IF END WHILE Step 1 and 2 Complete F T F T Array Variables Table Expression evaluator

58 F T 13. T foundsearchKeypos 1.FALSE (5)3. 13 (6)(9)(12)4. 0 (5) (6) 13.TRUE (14) Array2. numList [0][1][2][3] 8 (6)9 (9)13 (12)4 Variables Table SET found TO FALSE SET numList TO [8,9,13,4] RECEIVE searchKey FROM (INTEGER) KEYBOARD SET pos TO 0 WHILE found  TRUE AND pos < length (numList) DO IF numList [ pos ] = searchKey THEN SET found TO TRUE ELSE SET pos TO pos + 1 END IF END WHILE 6numList[ pos ] = searchKey numList[ 0 ] = 13 8 = 13 False 9numList[ pos ] = searchKey numList[ 1 ] = 13 9 = 13 False 12numList[ pos ] = searchKey numList[ 2 ] = 13 13 = 13 True Expression evaluator Step 3 Complete- F Hand execute program with 13 as input for searchKey 1.1. 2. 3.3. 4. 5. 6. 9. 12. 7. 10.. 8.11.14.. 15.

59 Other strategies Debugging code -Give students some code with 10 errors in (a mixture of syntax, logic and runtime errors). Ask them to circle all the errors. Commenting code -Give students some code and ask them to write a comment under each line describing what it does. 59

60 Summary Intuition Reliance on the other persons experience and ability to deal with ambiguity. Precision doesn’t really matter Reliance on copying other examples that might be similar. “The computer doesn’t like me and is being awkward” Understanding Realisation that a computer has no prior experience and struggles with ambiguity. Precision is crucial Choosing features based on what you want the computer to do. “I haven’t correctly described the process” 60

61 Topic 3: Pair programming  Pair programming started in industry as an agile methodology  The idea is to have two people at the keyboard, one as the “driver” and the other as a “navigator”.  The two people in the pair swap roles regularly while working  There is significant evidence that having two people at the keyboard helps productivity in industry What about school? 61

62 McDowell, C., Werner, L., Bullock, H. E., & Fernald, J. (2006). Pair programming improves student retention, confidence, and program quality. Communications of the ACM, 49(8), 90-95. Evidence that it works in university settings, for example in introductory programming classes Another article by Linda Werner et al suggests it supports engagement by girls/women Now starting to see evidence from school, eg Werner, L., & Denning, J. (2009). Pair programming in middle school: What does it look like?. Journal of Research on Technology in Education, 42(1), 29-49. 62

63 Research from US (middle school = KS2/3) Results  Pairing is effective generally  Mixed-ability pairing is good  Students who have “different views on collaboration” don’t program well together Denner, J., Werner, L., Campe, S., & Ortiz, E. (2014). Pair Programming: Under What Conditions Is It Advantageous for Middle School Students?. Journal of Research on Technology in Education, 46(3), 277-296. 63

64 Task: pair programming In pairs decide on who will be the navigator and who will be the driver/pilot. Every 5 minutes you can swap but NOT BEFORE. Your task is to take the algorithm written in pseudocode here and write in a programming language. Rules: - the pilot controls the mouse and keyboard - the navigator gives instructions 64

65 Breakout group exercise Which of the other presented strategies do you think might be useful? Which of these might you use? What other activities might work? 65

66 Objectives of today We will look at a variety of strategies and approaches to the learning of programming, and the theory behind these.  Tinkering vs planning when learning programming  Working with visual vs text-based environments  Pair programming to support learning of programming  Strategies for working with code  Peer Instruction  Program functionality  Visualisation mechanism (taken from PLAN C materials)  Debugging exercises  Commenting code 66


Download ppt "Teaching and learning programming DECEMBER 18 TH SUE SENTANCE 1."

Similar presentations


Ads by Google