“But it looks right”: Bugs in non-majors media programs Mark Guzdial College of Computing/GVU Georgia Institute of Technology.

Slides:



Advertisements
Similar presentations
Register Allocation CS 671 March 27, CS 671 – Spring Register Allocation - Motivation Consider adding two numbers together: Advantages: Fewer.
Advertisements

Sound, Part 3. Multiple Echoes Here is a recipe to create multiple echoes: def echoes(sndfile, delay, num): s1 = makeSound(sndfile) ends1 = getLength(s1)
CS1315: Introduction to Media Computation Introduction to Programming.
Created by Mark Guzdial, Georgia Institute of Technology; modified by Robert H. Sloan, University of Illinois at Chicago, For Educational Use. CS.
Sound, Part 2 Using range to manipulate samples by index number.
Six compound procedures and higher-order procedures.
Debugging CMSC 201. Announcements Hw2, Hw3 grades returned if something doesn’t seem right, ask Midterm next Thurs (Oct 23) we’ll review on Tues no hw.
Some Utility Functions If you know the name of the file, searching for it with pickAFile() feels tedious You can set and get a media folder (path) for.
Power Point Demonstration Capabilities of Microsoft Power Point 2003.
SharePoint document libraries I: Introduction to sharing files How to add and edit files Wondering how to actually work with a document library? You’re.
Random Stuff Colors Sizes CSS Shortcuts. Learning Objectives By the end of this lecture, you should be able to: – Identify the 3 most common ways in which.
TOPIC 9 MODIFYING PIXELS IN A MATRIX: COPYING, CROPPING 1 Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach.
Copying and Transforming Pictures. First, finding the min or max… Next homework asks you to write a function to find the darkest and lightest shade of.
NestedLoops-part31 Nested Loops – part 3 Barb Ericson Georgia Institute of Technology Nov 2009.
CC0002NI – Computer Programming Computer Programming Er. Saroj Sharan Regmi Week 7.
Introduction to Computing and Programming in Python: A Multimedia Approach Chapter 7: Modifying Samples in a Range.
Adding Content To Your Faculty Page 1.Login 2.Create your Faculty Page 3.
CS 0.5: A Better Approach to Introductory Computer Science for Majors Bob Sloan, Pat Troy University of Illinois at Chicago SIGCSE 2008.
CS 101: Introduction to Computing Programming picture manipulations Developed by Mark Guzdial, Georgia Institute of Technology, 2003–2004; modified by.
Georgia Tech’s Three CS1’s CS1321: Introduction to Computing Based on How to Design Programs and the TeachScheme Project Was the only CS1 course, on a.
ICAPRG301A Week 4Buggy Programming ICAPRG301A Apply introductory programming techniques Program Bugs US Navy Admiral Grace Hopper is often credited with.
02-RangesInPictures1 Barb Ericson Georgia Institute of Technology Oct 2010 Working with ranges in pictures.
Contrasting Women’s Experience in CS at Different Institutions Mark Guzdial College of Computing/GVU Georgia Tech Our Goal: Ubiquitous Computing Education.
A CS1 Course Designed to Address Interests of Women Lauren Rich¹*, Heather Perry, and Mark Guzdial* College of Computing/GVU Georgia Tech *Presenting¹Now,
CS1315: Introduction to Media Computation Referencing pixels directly by index number.
Oct 15, 2007Sprenkle - CS1111 Objectives Creating your own functions.
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
CS1315: Introduction to Media Computation Introduction to Programming.
Hey, Ferb, I know what we’re gonna do today! Aims: Use formatted printing. Use the “while” loop. Understand functions. Objectives: All: Understand and.
CS1315: Introduction to Media Computation Making sense of functions.
Chapter 7: Modifying Samples in a Range. Chapter Objectives.
CS 100 Introduction to Computing Introduction to JES Developed by Mark Guzdial, Georgia Institute of Technology, 2003–2004; modified by Robert H. Sloan.
Georgia Institute of Technology Processing Sound Ranges Barb Ericson Georgia Institute of Technology July 2005.
UsingSoundRanges-part21 Processing Sound Ranges part 2 Barb Ericson Georgia Institute of Technology Oct 2009.
Introduction to Computing and Programming in Python: A Multimedia Approach Chapter 7: Modifying Samples in a Range.
Program Design and Debugging. How do programmers start? How do you get started with a program? “Programming is all about debugging a blank piece of paper.”
Unit 1 – Improving Productivity Instructions ~ 100 words per box.
1 CS 177 Week 5 Recitation Slides Mirroring and copying images, Using for Loop, if statement, and range.
CS 101: Introduction to Computing Rotating and Blurring Developed by Mark Guzdial, Georgia Institute of Technology, 2003–2004; modified by Robert H. Sloan,
Chapter 4: Modifying Pixels in a Range (partial slide deck)
Introduction to Computing and Programming in Python: A Multimedia Approach Chapter 4: Modifying Pixels in a Range.
CS 101: Introduction to Computing Color replacements and targeted color replacement (if statement) Developed by Mark Guzdial, Georgia Institute of Technology,
Great Principles of Computing: Computing for Everyone Mark Guzdial College of Computing/GVU Georgia Institute of Technology.
CS1315: Introduction to Media Computation Color replacements and targeted color replacement (IF)
Collage Assignments So you’ve used Daniel Zingaro’s Stereo Sound Processing or Kevin Wayne’s Guitar Heroine. Or maybe you’ve used Joshua Guerin and Debby.
CRE Programming Club - Class 2 Robert Eckstein and Robert Heard.
Sight Words.
Chapter 8: Modifying Samples in a Range. Chapter Objectives.
CS1315: Introduction to Media Computation Introduction to JES.
CSC 112Introduction to Media Computation 1 Rotating Images.
1 CS 177 Week 8 Recitation Slides JES Sound functions and Modifying Sounds Increasing/Decreasing Volume Maximizing (Normalizing) Splicing Reversing Mirroring.
CS1315: Introduction to Media Computation Introduction to Programming.
CS1315: Introduction to Media Computation Transforming pictures by index number.
Barbara Ericson Promising Practices in CS1 Media Computation for CS1 Barbara Ericson Georgia Institute of Technology.
Python - Iteration A FOR loop is ideal if we know how many times we want to repeat. Try this code: for loopCounter in range(10): print(loopCounter) There.
CS1315: Introduction to Media Computation Introduction to JES.
Working with Sounds Barb Ericson College of Computing Georgia Institute of Technology
How To Format Your Note Cards
CS1315: Introduction to Media Computation
Picture Functions ppp =makePicture(pickAFile())
Chapter 8: Making Sounds by Combining Pieces
Working with ranges in pictures
Optimizing Malloc and Free
Chapter 7: Modifying Samples in a Range
Mark Guzdial College of Computing/GVU Georgia Tech
How sound works: Acoustics, the physics of sound
Chapter 7: Modifying Samples in a Range
Processing Sound Ranges part 2
Processing Sound Ranges
CS 177 Week 9 Recitation Slides
Presentation transcript:

“But it looks right”: Bugs in non-majors media programs Mark Guzdial College of Computing/GVU Georgia Institute of Technology

Context of Course Required introduction to computing and programming in Python for Liberal Arts, Biology, Architecture, and Management majors. Students learn to program by implementing Photoshop-style filters, splicing/reversing sounds, generating/searching Web pages, and creating animations. Emphasis on reuse and program modification

“Invisible” bugs we’re focusing on “They’re just small changes” “Seemingly appropriate patches” Bugs that students fall into by making changes that they consider small, insignificant. The code always looks right Usually an indicator of not understanding the change or the original program. May also be an indicator an inappropriate user model (where the user may be the TA)

Example 1: From Testing to Meeting Requirements Homework #1 is to posterize a picture (reduce colors) in a specifically-defined way. The assignment requires the function hw1() to accept a picture object as input.

Student’s attempt They get the function working like this, for ease of testing: def hw1(): file = pickAFile() picture = makePicture(file) # Posterizing goes here show(picture) Then, when they get ready to turn it in, they change it like this to meet requirements: def hw1(picture): file = pickAFile() picture = makePicture(file) # Posterizing goes here show(picture) “But why won’t it work with the input image?”

Two problems at work here Yes, the students don’t understand (at this point) how function inputs work. But there’s also a misunderstanding that the user (the grader) knows to call the homework function with an input. “The homework says that the function hw1 should accept a picture as input...does that mean that the user will type in pict=pickAFile(), picture=makePicture(), and then hw1(picture), or do we need another function to do this for the user?” “Do we need to have our function show the picture or save it (as a file) as well? But if we don't show the picture, how will the TAs see the final image?”

Example 2: Iteratively making small changes Homework #3 requires creating an audio collage. Must splice two different sounds together. Must compose one of the sounds twice, the second time with some kind of modification: Reversed, volume manipulation, frequency manipulation, sub-spliced, etc. SoupStephen Hawking

We give them backwardSound() def backwardSound(filename): source = makeSound(filename) dest = makeSound(filename) sourceIndex = getLength(source) for destIndex in range(1, getLength(dest)+1): sample = getSampleValueAt(source, sourceIndex) setSampleValueAt(dest, destIndex, sample) sourceIndex = sourceIndex - 1 return dest

Student’s attempt def hw3(): … backsound=backwards(sound1) … def backwards(file): source = file target = file sourceIndex = getLength(source) for targetIndex in range(1,getLength(target)+1): sourceValue = getSampleValueAt(source,sourceIndex) setSampleValueAt(target,targetIndex,sourceValue) sourceIndex = sourceIndex -1 Note that the previous code handed in a file, to make two distinct sounds from. That’s been lost here. Was that return really all that necessary?

Getting lost in the debugging process The code that we’re seeing from the student is actually several iterations down a debugging path. The strategy the student used was to remove extraneous code—not a bad strategy. The original backwards use of making a sound (to make distinct source/target sounds) seemed redundant, so that was removed. Return disappeared since that didn’t seem to do anything useful! At this point, the student has generated such buggy code that it’s hard to get back.

Indicating misunderstanding of the original program The student didn’t understand what return did (very common among the non-majors before half-way through the term) nor why two copies of the sound were made. Rather than try to understand what was confusing, she simply removed it. Each change seemed small, so at each step, the code looked just fine.

Example 2b: Too many returns def hw3(): #Establish sound files file = getMediaPath("canvas.wav") dest = makeSound(file) file1 = getMediaPath("gg_boom.wav") boom = makeSound(file1) file2 = getMediaPath("sh_madman.wav") madman = makeSound(file2) file3 = getMediaPath("bj_mommy.wav") #"Mommy mommy mommy" with volume changes #Add quiet volume "mommy" quietMommy = makeSound(file3) for sample in getSamples(quietMommy): value = getSample(sample) setSample(sample, value*0.5) return quietMommy source = quietMommy destSample = 1 for srcSample in range(4257, 8133): sampleValue = getSampleValueAt(source, srcSample) setSampleValueAt(dest, destSample, sampleValue) destSample = destSample + 1 return dest … There were 6 more loops and 6 more returns after this. Again, the student didn’t really understand the role of the original functions that he’s combining into his audio collage. So, he simply copied EVERYTHING—including each and every return Each loop looked like the original example function, so it must be right!

Example 3: Where looking right should be enough Python uses indentation to indicate block structure. No curly braces, no BEGIN..END When it works well, the advantage is that if the code looks right, it is right But in long programs with nested loops, it’s pretty easy to be off by a space somewhere

def hw2(): puppy=makePicture(getMediaPath("puppy.jpg")) print puppy canvas=makePicture(getMediaPath("7inX95in.jpg")) print canvas #First picture, at left edge targetX=1 for sourceX in range(1,getWidth(puppy)): targetY=getHeight(canvas)-getHeight(puppy)-5 for sourceY in range(1,getHeight(puppy)): px=getPixel(puppy,sourceX,sourceY) cx=getPixel(canvas,targetX,targetY) setColor(cx,getColor(px)) targetY=targetY + 1 targetX=targetX + 1 #Second picture, puppy negated negative(puppy) targetX=122 for sourceX in range(1,getWidth(puppy)): targetY=getHeight(canvas)-getHeight(puppy)-5 for sourceY in range(1,getHeight(puppy)): px=getPixel(puppy,sourceX,sourceY) cx=getPixel(canvas,targetX,targetY) setColor(cx,getColor(px)) targetY=targetY + 1 targetX=targetX + 1 Do you see it? The second loop never got indented back out to the level of the function block, so the next two loops are actually inside the for sourceY loop

Suggestion: Relying on “Looking right” passes Relying on code “looking right” is a developmental stage. The problems described here are common in the first three homework assignments in our class (first six weeks). By week 15 (five programs later), they don’t happen. Students learn not to trust what the code looks like But understanding these early misconceptions may help us ease the transition for the students. And maybe keep more students in CS