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.

Thursday, February 25, 2021

How Should We Evaluate High School Teaching Records?

Mark Guzdial posted several articles about evaluating the teaching records of undergraduate faculty. (Links below) They really got me thinking. Now evaluating secondary school (high school) and university teaching is pretty different. Class sizes are the most obvious difference especially in large universities. First and second year computer science courses in universities can have hundreds of students. One can’t teach 600 students the same way one teaches 20. University faculty also have different supports which often include teaching assistants to manage labs, help with grading, and other assistance.

So the question becomes, how to you evaluate the teaching record of a high school CS teacher? Some obvious things to look at as student evaluations, and student results on standardized tests like the AP CS exams. I’m not a fan of either of those. I had a class of highly capable students one year who just decided they would blow off the AP exam for a variety of reasons. They told me they did it. being evaluated on that year’s test results would have been a big mistake. I think most teachers would agree that there are things far outside a classroom teacher’s control that impact test results. COVID-19 anyone?

Student evaluations are also unreliable. Male teachers tend to be rated higher than females' teachers.  Fun and/or  easy teachers get evaluated higher than “hard” teachers whose rigor helps students learn more. And generally, students are not that good at evaluating teachers.

I think that peers and administrators at the high school level have a better idea of what a good teacher is/does than university faculty so I would give weight to peer/admin evaluations. Of course, being able to watch a teacher teach would be ideal. The time I did interview for a university faculty job teaching two classes was part of the process. I think that is very helpful.

I would also like to see what a teacher does to improve their practice. What are they doing for professional development? Are they taking workshops? Attending conferences? Online conferences are making that more affordable and practical? Do they read – articles, blogs, etc.? I have maintained membership in SIGCE for years to get access to research on how to teach and found that very helpful for my professional growth.CSTA has been great as well opening up chapter meetings, the annual conference, the publications, and general community building.  I would ask what things they have learned from others and added to their practice.

Importantly, what does a teacher do now differently from when they started teaching? There is a difference between one year of teaching ten times and ten years of teaching.

I should add that I want to know how they are growing their content knowledge over time as well. But pedagogy improvement is really critical. Teaching the way we were taught years ago is probably not the best way to teach.

Live long learning is something teachers should model so I want to see (read) how a teacher candidate does that.

What else should one look for in evaluating a teacher’s record?

Posts by Mark Guzdial that are related

Monday, January 25, 2021

Does Bad Code Lead to Good Learning?

Last week a teacher posted an interesting problem. They were looking for an explanation of why to code produced the answer that it did. The code is this:

    static void Main(string[] args)
     {
         int x = 2;
         while (x < 12 || (x % 3) != 0)
         {
             x += 3;
         }
         Console.WriteLine(x);
     }
}

The answer, which takes a while to appear, is 12. But why? It turns out that the value of x overflows. It overflows a lot! Eventually the combination of overflows results in a 12 appearing. It’s not at all obvious how this happens or even why this is not an infinite loop.

There was a lot of discussion of this in the AP CS A Teachers Facebook group. I did find it fascinating and wrote some debugging code to see what was going on.

I have to wonder about the value of showing this code to beginners. Or anyone really. What is the value of the learning, if indeed it does teach anything that beginners are ready to learn. Mostly it is not a great plan, in my opinion at least, to rely on number overflows. Different architectures, especially those with different work lengths, are going to take different numbers of iterations. Are they some that would never get to 12? I’m not sure and I don’t like relying on specific architectures.

BTW on my system with a full word this took 1,431,655,765 overflows. With a short it happens after 21,845 overflows. I still don’t know why it takes so many overflows but I am content for now.

In any case, is there value in asking students to figure out why 12 comes out?  I can see people disagreeing on its value as an exercise in debugging. I’m not a fan of it though for a couple of reasons. Firstly, why would you write that code? What is its value? Some people will find it to be an interesting puzzle for the sake of solving a puzzle. I did. But not everyone is “in to” such puzzles.  I think most people want to solve a problem to make something work and do something interesting.

I’m also not fond of code that is unclear as to its purpose and goal. In the Facebook group there were a lot of comments from experienced teachers who expected something completely different from the code. Infinite loops being the most common expectation. In fact, that this isn’t an infinite loop is highly unexpected. Code should be written so that someone can figure out what it does without actually executing the code. Especially for beginners.

Now I am not going to be critical of a teacher who does see value in this particular exercise but it’s not for me. As educators we often do create code just for the purpose of highlighting a specific language feature and small, not very useful pieces of code, often make up quiz/test questions for the sake of space and time. But for the most part I believe that students learn better with more context and with code that solves an interesting – to them – problem.

Related posts:

Tuesday, January 19, 2021

Scratching the Programming Itch

Programming is fun for me. It always has been.I’ve always written code to scratch a personal itch. That is to say that I like to write programs that interest me. If I can learn something new or try something different that is a plus. Not having a time pressure makes this even more enjoyable. I’ve written a couple of fun programs lately. I think they have some potential for student projects as well.

For example, my wife bought us some clothing from a company called Two Blind Brothers. It’s nice clothing and profits go to fight blindness according to the web site. The clothing all has labels in the braised bumps of Braille. Naturally one wants to know what the Braille says and while it is probably documented in the company web site I was looking it up letter by letter with a chart. Eventually I decided to write a program to help me out. Yes, programmers will spend an hour writing code to save themselves 5 minutes.

My program has a pattern of 6 dots that can be set or unset to match a Braille patter with the program displaying the appropriate letter. Or I can enter a letter and the program will display the pattern.

I’d love to assign this to students just to see the different ways students come up with to do the parsing and display. I’m probably going to use it as a platform for more experimentation. I have some other ideas about parsing and translating. It’s modular enough to make experimentation easier.

I’ve also been playing with a Yahtzee program. There are a lot of interesting facets to this program. One of them is verifying options. How do you recognize a full house? How do you recognize a straight? How do you make sure the values entered for a Chance or a three of a kind at legitimate? A couple of years ago I thought about using this as a project to use and enhance over the course of a semester. I ran out of time developing that but now that I have a program almost finished I may try to write up something like that.

Loops, arrays, classes (dice class anyone?) and more are all part of a project like this. It’s been fun writing it. I’ve learned a few things that may help me with some additional games.

Friday, January 15, 2021

Comments on Commenting Code

Comments sometimes seem to be a hot button for software developers. Opinions range from the manager I had who actually did want a comment on every line of code to the people who think comments are completely unnecessary. I tend to fall somewhere in the middle as I think most people are. We may draw the line differently but most people think there is a sweet spot for how many comments are a good idea.

Some people don’t see the value in comments. They believe that code should be self documenting. The variables and functions should have descriptive names for example. To some extent that is a valid goal. Code should be understandable by itself. That’s not always as easy as it seems. When we write code we do so with some specific, obvious to us at the time, information. This might not be the case for others who come to the code later. Or even to the original programmer after some time has passed.

When I talk to students about comments I often relate an experience of my own. I wrote a really cool (in my opinion) program while I was a university student. It drew pictures on a drum plotter. Pictures took about a half hour to draw on that device. Some years ago, decades after I wrote the original program, I decided to write the program again for a modern display device. I wrote the program, compiled it, and ran it. It didn’t look right at all. I stared at the screen and thought “that looks familiar. I think I made that mistake the first time.” Now it turns out that I still had the punch card deck (yeah, I’m that old) and could read through the original program. I came across a comment that read “this function takes degrees in radian” Ah, ha! That is what I got wrong both times. I simple fix and my program worked as I wanted.

Clearly writing comments, especially that one, paid off big time.

Something that took a while to figure out should always be commented in my opinion.

When ever the subject of comments come up someone brings up the case where code changes mean that comments do not match the code. There is no doubt that this happens but frankly I have no sympathy for the situation. A serious professional should be mindful of details like that in their code. When the code and comments do not match it means someone was in too much of a hurry to do a complete job.

Comments should document difficult things, non-obvious things (parameter lists to called methods are a good example, and anything that required some involved logic.

Student projects in a first programming course often don’t have the sort of complexity that a larger professional program might have so it is hard to get students to comment code. I always insisted on a complete header of comments at least. And a comment that describes the purpose of each method written. As I think on it today, I wish I had produced some larger piece of well commented code to have students read.

How do you feel about comments in code? And how do you communicate it to students? Please share some ideas in the comments.

Monday, January 11, 2021

Early Registration Open for the CSTA Annual Conference

Just registered for the 2021 CSTA Annual Conference Early discounted registration for CSTA+ members is now open https://web.cvent.com/event/354be991-0b98-48e0-b4d3-0e32b72a6e49/summary

If you are a CSTA+ member you should have the email.. If you’re not a CSTA+ member maybe you should think about becoming one!

I think its going to be a great conference. We learned a lot from last years conference on many levels.

Saturday, January 02, 2021

Recursion–How and When to Teach

I’ll start with a confession. Recursion is one of those concepts that I struggled to understand in the beginning. Was it me or was it how it was taught? An open question that I don’t want to look for blame. A recent article by  Shriram Krishnamurthi, CS Professor at Brown University, called How Not to Teach Recursion suggests that maybe I was taught badly and worse still that I taught it badly.

Adam Michlin wrote an interesting, related, post called Why you shouldn’t teach recursion (yet)

The teaching of recursion is one of those topics that really gets people talking. I hope thinking as well. Certainly I have been thinking about it lately.

Teaching it early, teach it late (as Adam suggests), not teach it at all? All question people ask and answer differently.

My key takeaway is that recursion has to be the natural solution to a problem for it to really make sense to students. Navigating a tree structure, file directories for example. This implies a prior understanding of the related data structure is also required.

Some languages and teachers use recursion for iteration. I guess for some that feels natural but it never has for me. Perhaps I am to old school and too deep into for statements and while loops. When I started programming there were languages that didn’t support recursion at all!

I have had several students discover recursion (and stack overflows) by having the main function call itself. Very instructive.

I’ve been programming for about 48 years now and very seldom have I had a real need to use recursion. By need, I mean that was the bests and only way to code a solution. One time I wrote a really cool recursive method which I was writing code for a living. Upon code review the rest of the team made me rewrite it as an iterative method because they decided it was too complicated and no one else wanted to try to debug it some day. Most of the teach was fairly young and were recent graduates from top CS universities too!

How important is recursion really? The AP CS A exam tests it lightly in the multiple choice questions (as I understand it). The AP CS Principles didn’t test it at all. SO if you are basing decisions on those exams (which is a whole other problem IMHO) its not that important. Do an advanced data structures course on the other hand it is probably fairly important.

If you are teaching it though I think the important things are outlined in Shriram ‘s article. The popular examples are problematic at best. From the post:

Where does recursion come from? HTDP argues that it arises from self-references in data. That is, recursive data suggest recursive solutions. This is the key insight you need for understanding recursion. Not only does it make sense once you think about it, it also demonstrates why most other approaches to teaching recursion are essentially incorrect.

But do read Shriram’s article. He explains it much better than I can.

[Edit: Mike Zamansky gives some thoughts on teaching recursion at On Teaching Recursion
Worth the read. ]

[Edit: Michele Lombardi gives here thoughts at Chiming in on Recursion

Friday, January 01, 2021

Looking Forward to 2021 in CS Education

What a strange year it has been. The pandemic and more took a lot of the steam out of what I had hoped to dig deeply into in 2020. Surviving is success in these times I guess. I taught online for the winter/spring semester of 2020 and then retired. Teaching online was not so bad but it didn’t leave me with much time to improve on things. Running as fast as possible to stay in the same place seems to have been the norm for most teachers.

But this is time to look forward not back. One thing that seems to have grown among the teachers I see on social media is cybersecurity. While we have seen cyber security at the CSTA conference the last several years is feels like 2020 was the year teachers started teaching it in larger numbers. I think that is only going to continue.

I see a lot of teachers looking for new courses that are relevant to students and cybersecurity certainly counts as that. We can also fit more of it into other CS courses. Students love it. Well, mostly.

CYBER.ORG (formerly NICERC) is one of several organizations supplying curriculum and professional development. And it is all free.I love that team.  Teach Cyber  is  another group as is TryHackMe There is a pretty active Cybersecurity Educators group on Facebook where a lot of teachers are sharing ideas and resources. I highly recommend that group.

Other than cybersecurity what am I looking to see more of in 2021? Well, online IDEs which really came into their own in 2020 are going to only get better. We’ll probably see more competition there as well. In fact, any option for teaching online will see growth even if, as we all hope, schools all return to in-person learning. Giving access to students outside of computer labs is just too powerful a tool to avoid.

I expect computer science, indeed most, conferences to retain a virtual component in 2021. Will they be mixed with both in-person and virtual aspects? I’m not sure but I see more and more conferences having the ability for people to attend virtually. The cost of that is coming down for the conferences and the ability of teachers to spend money for airfare and hotels is not growing as fast as the need for more teachers. There is also a growing interest in reducing carbon footprints on that part of many people.

Computer science education research has been gaining traction in universities. That’s pretty exciting to me as I think there is still a lot we can learn about how to teach CS more effectively. I am hoping that learning about the results of this research will be more available to teachers as well. We can’t all go to conferences or afford expensive peer reviewed journals. The real value of CS Ed research is getting the knowledge to actual teachers.

I see reason to be optimistic about CS education in 2021. We made it through 2020 and it is all going to get better. I can’t wait to see what happens!