Monday, March 29, 2021

Learning To Teach To Learn

A blog post by Eugene Wallingford  (TEACHING YOURSELF THE MATERIAL) reminded me of some things. As he says, “A common complaint from students is that the professor makes them teach themselves the material.” During a graduate course I took in distributed Operating systems the professor assigned each student a topic to research and then teach to the class. I had a couple of peers who complained (privately) that it was his job to teach not theirs. I took it as an opportunity to dig deep in my topic and came away thinking it was a great learning experience.

As a teacher myself, I assigned topics to students to research and teach to the class on several occasions. I’m not sure if students complained behind my back but they were pretty good in my hearing. I found that this was beneficial to the students as well as to myself. In several cases students found features or uses that I had not considered. Students seem to lesson to peers more closely than to their teacher.

I also asked each students to write a couple of quiz questions (with answers) for me to use in a quiz for the whole class.The quality of the questions was mixed as one might expect but they also gave me insights into what students saw as the important part of their topic.

One thing I should have done is to have more rounds of this sort of thing. Students need to practice how to present material. One would like to think that they have enough examples of how to present from sitting through presentations day after day but that doesn’t seem to be the case. Students definitely need some more formal training in presentations than most of them get.

Do you assign students to research and teach topics? How does it work for you?

Tuesday, March 23, 2021

Too Many Ways to Add One

Someone posted a questions asking which sort of programmer one was from a list of ways to add one to a variable:

X++
++X
X+=1
X = X + 1

Actually the initial question didn’t include ++X but it soon showed up in replies. With all these ways to do what appear to be the same thing it is no wonder students get confused.

Daniel Moix replied to my Facebook post with X = X++ This doesn't work (at least not in C# or Java). While one might expect that the value in X would be increased by one after the statement executes it is in fact unchanged. X = ++X does work as you would expect though. It’s not surprising that students, clever people that they are, come up with variations that should work in their eyes but do not work.

Why do we have so many ways to add one? I can’t speak for the language designers (I assume most of this started with C or some earlier language) but lots of us like shortcuts. And it seems like every programmer has his or her own idea of how things should be done. There are few programs that have been around for any length of time that have only one way to do anything.

All of this is great for experienced programmers but can be a nightmare for novices. I used to debate in my head if I should even show all of the ways above.  X=X+1 and X++ covers most cases for beginners. Why confuse them?

I usually did briefly talk about X+=1 because a) students are likely to see it in other code and b) it is useful when adding (and other operations) where one is not changing by one.

This all adds some cognitive load. I think that teaching all the various ways at one time can be a bit much. It may be better to add things as they are needed. For example, maybe waiting until teaching loops to introduce X++ and X+=1. That context and specific use may be helpful. I didn’t do that before but I wonder if I should have. Opinions are welcome.

Wednesday, March 17, 2021

Programming using Text or Blocks? Why not Both?

Continuing my look at papers from the SIGCSE 2021conference. The papers are available for free for a limited time. Get them while you can. In this post,  I take a look at Dual Modality Instruction & Programming Environments: Student Usage & Perceptions.

This paper took a look at the usage of Dual Modality IDE with students. Dual modality means that the IDE is capable of switching between text based programming and block based programming. The authors used the JetBrains plug-in Amphibian which creates Java code. While teaching AP CS Principles using the code.org curriculum, I used AppLab from code.org with students AppLab is also Dual modality though with JavaScript rather than Java.

I was curious to see if the author’s conclusions matches my far less rigorous observations. They basically did. That is to say that they saw students using the blocks to learn concepts and gradually move to text. Blocks often become a reference for learning concept and less for developing program solutions. I noticed much the same thing. Students might also use blocks to learn and switch to text when writing final solutions.

In my course, I did not mandate either blocks or text but let students switch at will. What I noticed is that students with a prior programming background in text moved to mostly text much sooner than students with no prior programming. Some students seldom used text even near the end of the year. This did not seem to impact final grades in my classes. As the authors of this paper found, I saw even the very comfortable with text students use the blocks to explore new concepts.

If you are thinking about dual modality environments (or not) I recommend this paper. I think you will find it supports the value of this sort of environment.

Are you using a dual modality environment? What are you seeing with it?

Monday, March 15, 2021

Zero Indexing Considered Harmful

As the old computer geek joke goes. the three hardest things in programming are naming things and off by one errors. Lately I have been thinking about off by one errors and wondering if having array and similar indexes start from zero rather that one is contributing the off by one errors by novice programmers.

I understand why many programming languages start indexes at zero. It’s a natural outgrowth of pointer arithmetic. After all if the pointer is to the beginning of an array or other data structure the first element is an offset of zero. The language could hide this though. In fact, FORTRAN and several other languages do start at 1. I used to use a version of BASIC (Basic-Plus) where not only was the first element an index of 1 but a programmer could specify the low and high index of an array at what ever numbers they wanted. Individual characters in a string could be accessed as if they were in an array as well. The first letter was at index of 1. An index of zero held the length of the string.

So we don’t have to start at zero. Does it matter? I don’t have any studies or data (someone please research this for their PhD) but I suspect that starting from zero promotes off by one errors especially for novices.

Getting beginners to grok that the first element in an array is zero is a struggle. It seems like a great many of novice errors come from assuming that the first item is a list is item number 1. I see the same issue with loops. Going from zero to less that some value does not come as easy to beginners as from 1 to some value.

So there is my theory, starting from one is better than starting from zero and could reduce off by one errors. As the meme goes, prove me wrong.

Thursday, March 11, 2021

What’s Up with Novice Programmers and Comments

Continuing my look at papers from the SIGCSE 2021conference. The papers are available for free for a limited time. Get them while you can. I take a look at Usage of the Java Language by Novices over Time: Implications for Tool and Language Design.

The BlueJ tool for teaching Java has the (opt in) ability to collect data on language usage by the novices who use it. This is a valuable research tool and the authors of this paper have taken a good look at it for a number of research questions. I recommend the paper for more insights but I was particularly struck by one finding. Students, in large numbers, delete the comments that BlueJ inserts in code automatically.

BlueJ adds stub JavaDoc comments (which can be used to generate documentation) into objects that are created. Over 45% of projects analyzed had no JavaDoc comments in them Students had gone out of their way to delete them. Not answered in the paper but I suspect many of the comments were not expanded from the default either.

What is it with students and comments? In my own teaching I often created stub projects with comments as sub-goal labels. In several cases I saw those comments deleted before coding started. In other cases the comments were left completely separate from the code created in ways that suggest they were ignored. I know that students don’t see the value in adding comments to their code. Is that our (educators) fault? I know that most of us try to teach good commenting practice but at the same time the projects we assign are easy enough to understand (usually) without comments. But why ignore comments clearly designed to help students?

What’s going on here? This looks like a great research question to me. I wonder if anyone is looking at it? What do you think?

Wednesday, March 10, 2021

Inch by Inch–The Inchworm Problem

I am reading a bunch of papers from the SIGCSE 2021conference. The papers are available for free for a limited time.Get them while you can. I started with Exploring the Inchworm Problem's Ability to Measure Basic CS Skills

The Inchworm problem has been around for a while but was new to me. It’s an interesting problem for beginners for sure. Here is the description from TopCoder:

The inchworm is a creature of regular habits. She inches forward some distance along the branch of a tree, then stops to rest. If she has stopped at a leaf, she makes a meal of it. Then she inches forward the same distance as before, and repeats this routine until she has reached or passed the end of the branch.

Consider an inchworm traveling the length of a branch whose leaves are spaced at uniform intervals. Depending on the distance between her resting points, the inchworm may or may not be able to eat all of the leaves. There is always a leaf at the beginning of the branch, which is where the inchworm rests before setting out on her journey.

You are given three int values that specify, in inches: the length of the branch; the distance traveled by the inchworm between rests; and the distance between each consecutive pair of leaves. Given that the inchworm only eats at rest, calculate the number of leaves she will consume.

There is a bit more to the description but that's a start. There were 5 basic ways the paper’s authors found students use to solve the problem. Four are simulations and one is purely mathematical. I confess that a simulation was my first thought about a solution. The mathematical solution is much faster than the simulations.

The paper included multiple solutions and I found a solution on TopCoder pretty easily. That demonstrates a problem typical of interesting programming problems – cheating is easy. The author of the paper use a couple of things to reduce cheating.

For starters, there are few grade points for a solution. I assume the idea is that students will not work too hard to cheat for small point values. I am skeptical of this idea myself. Secondly, and probably a lot more importantly, students were required to document their design and process in digital journals. I had mixed results asking students to document designs in high school. It may be better at the university level. 

Overall, this was an interesting paper and I like the new (to me) project idea. I was thinking about how it might be set up with hints but my fear is that too much scaffolding would force students into one solution rather than letting students get creative.