Post on 27-Dec-2015
On Teaching Introductory Programming
Abhiram Ranade
Background
• I recently taught the IITB introductory programming course, CS 101.– 700 students, varying preparation
– 60 Teaching Assistants
– Lack of a good textbook
– All usual teaching related issues: content, delivery.
• Report of personal experience.– Main focus: content and delivery
Outline
• The new student• Basic Premises on learning: motivation, fun.• Course Themes:
– Graphics– Every lecture must solve a nice problem– Depth helps learning– Connect to other disciplines– Cool Algorithms/Fun
• Concluding remarks
The New Student
• Less reverent than 20 years ago
• More oppressed in school years, expects more freedom in college.
• Wants to know why he/she should learn what is being taught
• Is swayed by immediate gratification.
• Has many distractions
Basic Premises on learning
• Motivation must be very clear– The student must develop ownership of the
questions being answered in the course
• Topics must be fun!
• Beauty vs. Utility? Beauty and utility.
Fun
• Eating ice cream
• Climbing a mountain
• Swimming or playing a sport
• Seeing a movie, natural panorama
• Seeing a magic show
• Learning should have all kinds of fun!
Fun and programming
• Sense of accomplishment: students should be able to do something significant of interest to themselves.
• Should relate CS to other sciences, even life!
• Should be surprised by cool algorithms. Must be occasions of “Wow!”.
Theme 1: Graphics + Turtle Geometry
• Available to students, from lecture 1. Used to teach many concepts:– Notion of program as sequence of instructions.– Iteration: repeated patterns– Recursion: recursive patterns– Procedures: draw_house();– Graphical debugging– Visualization: Trees, Newton’s method for finding
roots.
Turtle Geometry + Graphics (contd)
• Class heirarchy: Shape
Line Polygon Circle
Turtle
Introductory Lecture
• Traditional: Printing “Hello world”– Lots of syntax with little excitement.
• Instead: use graphics package to draw nice pictures. Non trivial picture drawing exercises from day 1.
• Lecture 1 sets the tone of the course.
Theme 2: Begin with a problem
• Every lecture begins with a problem:e g. we want to plot movement of gas particles on the screen.
• Can we do this using the language we know so far? No.
• Here is a new statement/concept which will help.
• Not: “Today we will learn about arrays..”
Theme 3: Depth helps learning
• For every concept have– good motivating examples
– discuss implementation, e.g. recursion, pointers
– interesting programming exercises.
• Generalization helps learning:– pointers: lists are good, but trees really force you to
learn!
• Mix ideas: Use graphics to draw out trees recursively...
Connect to Other Disciplines
• Newton’s method
• Simulate movement of charged particles
• Hemachandra (Fibonacci) numbers as they arise in counting the number of different possible poetic meters of n beats.
Cool Algorithms
• Newton’s algorithm• Searching trees: visualize with turtle moving on
the screen.• Shortest paths: good combination of
– matrix multiplication over +, min
– C++ supports representation of infinity: “HUGE_VAL” ==> very elegant, short code for computing shortest paths
– Students feel they are improving their math!
Fun!
• Graphics package includes X windows “event loop”: wait for event to happen and based on event do whatever.
• Used by many students to develop “video games” in final project
• Did not talk about event driven programming, listeners etc. because too much syntax.
General Remarks
• Carefully designed lab exercises. TAs graded them. Final weightage of labs was less because of fear of copying.
• Students liked assignments and said they helped learn.
• Switched to writing on board (tablet) because of student demand. Students said lecture developed better than slides.
• Some students found the course too mathematical.
What I would have liked to do but didnt
• String class examples• Assertions, reasoning about programs..• STL and algorithms class use.• Programming style• Debuggers/IDEs.
• Would have been possible with 3 lectures/week.