Presentation is loading. Please wait.

Presentation is loading. Please wait.

Worked Examples - Incremental Software Development Worked Example

Similar presentations


Presentation on theme: "Worked Examples - Incremental Software Development Worked Example"— Presentation transcript:

1 Worked Examples - Incremental Software Development Worked Example
Theory and Practice This technique uses the worked examples approach to work through the solution to a software development task.

2 Programming Example Here's the problem
Create a program that asks for three numbers, calculates the total and average and displays this information. and here's one possible solution: SET total TO 0 FOR step FROM 1 TO 3 DO RECEIVE nextNum FROM KEYBOARD SET total TO total + nextNum END FOR SET average TO total / 3.0 SEND "The average is " TO DISPLAY SEND average TO DISPLAY The problem here is one you may have seen before. Take some time to read it over. The problem given to pupils is at the top.

3 And here's the Worked Example: Step 1
Let's analyse the problem in order to develop a plan Reading the problem again Create a program that asks for three numbers, calculates the total and average and displays this information. and simply breaking the sentence into sections, it looks as though there may be three steps to the plan: PLAN ask for three numbers calculate total and average display this information A worked example will talk through the problem in detail. This may be done as class, individually or as a written exercise.

4 Step 2 Looking closely at the plan now – how do you calculate an average? Well – you total up the numbers first, don't you? And then you can do a division to get the average. So the plan needs to be more like this, with four steps, calculating the total BEFORE the average… PLAN ask for three numbers calculate total calculate average display this information Asking questions about the steps will help guide pupils to a way of constructing the answer. This should be interactive.

5 Step 3 The first step – ask for three numbers – this is really "read in three numbers". If we do this, where will we store them? In fact do we need to store them? No, we could just add each one directly to a running total, and then discard it. (Note – when reading in a series of numbers, it's always worth asking that question – do I need to store them all, or can I process each one as it comes in and then throw it away?) This allows us to merge the first two steps, so we now have… PLAN read in three numbers, adding them to a total calculate average display this information Talking through a process will reveal further steps that need to be dealth with. In this case, we realise that we need to add to a total.

6 Step 4 We now have a plan in sufficient detail, let's go ahead and implement it. The first step … read in three numbers adding them to a total … is a repetitive activity, requiring a loop. Q. Is it a fixed loop or conditional loop we need? More questions are used to tease out detail.

7 Step 5 We're doing something 3 times, and we know this at the point the loop starts to execute, so it's a fixed loop. (Remember, we'd use a while loop when we didn't know at the point the loop starts to execute how many repeats we'd be doing.) Let's add the fixed loop in: Program (in Haggis) FOR step FROM 1 TO 3 DO END FOR Some guidance on the code needed is provided. In the next task the pupil sits, this could be excluded in order to allow pupils to try the approach themselves.

8 Step 6 Inside the loop we're reading something in, so let's add that
Program (in Haggis) FOR step FROM 1 TO 3 DO RECEIVE nextNum FROM KEYBOARD END FOR More steps help the pupil elaborate on the current focus, which is to read in three items of data.

9 Step 7 And we're adding the number to a running total.
Does this look ok? Program (in Haggis) FOR step FROM 1 TO 3 DO RECEIVE nextNum FROM KEYBOARD SET total TO nextNum END FOR And adding in the total helps. Questions about code also help.

10 Step 8 No – this isn't right, as we're saying that the total will be the number just read in – no adding going on. We want to add the new number to the previous value that was in the total variable. Is that ok now? Program (in Haggis) FOR step FROM 1 TO 3 DO RECEIVE nextNum FROM KEYBOARD SET total TO total + nextNum END FOR

11 Step 9 Well, it's better, but it'll cause an error, as the variable total has not been created. We do this outside / in front of the loop. What value should total be initialised to? Program (in Haggis) FOR step FROM 1 TO 3 DO RECEIVE nextNum FROM KEYBOARD SET total TO total + nextNum END FOR A lot of alternative conceptions and common mistakes can be dealt with as you develop a solution.

12 Step 10 Setting a total to zero to start with is sensible.
Do you think we've completed the first step of the plan now? Program (in Haggis) SET total TO 0 FOR step FROM 1 TO 3 DO RECEIVE nextNum FROM KEYBOARD SET total TO total + nextNum END FOR We continue to build the program using questions.

13 The story so far… I hope you get the idea! Note the following:
we've been explaining our thinking process at each step – explaining our choices we've posed questions these help keep the reader engaged and active we've shown partially complete artefacts being developed e.g. the plan and then the Haggis program we've referred back to the original problem at times The process here shows how posing equestions and explaining choices builds understanding. To practice, try completing this example.

14 In summary We should use W.E.s
to scaffold (accelerate) development of problem solving templates to avoid a lot of pain!! In summary, Worked Examples are really useful for guiding pupils, allowing them to absorb some of the understanding that we have. It is a form of cognitive apprenticeship that helps develop understanding.

15 Next steps Incremental Software Development Worked Examples
Subgoal Labelling Calculation Worked Examples Incremental Software Development Worked Examples Relational Database Design Worked Examples In summary, Worked Examples are really useful for guiding pupils, allowing them to absorb some of the understanding that we have. It is a form of cognitive apprenticeship that helps develop understanding.


Download ppt "Worked Examples - Incremental Software Development Worked Example"

Similar presentations


Ads by Google