On Teaching Introductory Programming Abhiram Ranade.

17
On Teaching Introductory Programming Abhiram Ranade

Transcript of On Teaching Introductory Programming Abhiram Ranade.

Page 1: On Teaching Introductory Programming Abhiram Ranade.

On Teaching Introductory Programming

Abhiram Ranade

Page 2: 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

Page 3: On Teaching Introductory Programming Abhiram Ranade.

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

Page 4: On Teaching Introductory Programming Abhiram Ranade.

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

Page 5: On Teaching Introductory Programming Abhiram Ranade.

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.

Page 6: On Teaching Introductory Programming Abhiram Ranade.

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!

Page 7: On Teaching Introductory Programming Abhiram Ranade.

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!”.

Page 8: On Teaching Introductory Programming Abhiram Ranade.

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.

Page 9: On Teaching Introductory Programming Abhiram Ranade.

Turtle Geometry + Graphics (contd)

• Class heirarchy: Shape

Line Polygon Circle

Turtle

Page 10: On Teaching Introductory Programming Abhiram Ranade.

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.

Page 11: On Teaching Introductory Programming Abhiram Ranade.

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..”

Page 12: On Teaching Introductory Programming Abhiram Ranade.

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...

Page 13: On Teaching Introductory Programming Abhiram Ranade.

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.

Page 14: On Teaching Introductory Programming Abhiram Ranade.

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!

Page 15: On Teaching Introductory Programming Abhiram Ranade.

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.

Page 16: On Teaching Introductory Programming Abhiram Ranade.

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.

Page 17: On Teaching Introductory Programming Abhiram Ranade.

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.