Friday, March 22, 2019

Debugging Student Code for Fun and Learning

Students are really good at creating strange hard to solve bugs in their code. I am convinced that the code of a raw beginner can easily be harder to debug than that of a professional coder.

I had a couple of good ones today. One was actually pretty easy once I realized the cause. I have some international students. Great kids, very smart, hard workers. English is not their first language though. In fact, English letters are not their first character set. In one class I have boys from Cambodia and Viet Nam. The character sets they grew up with are very different from English characters. This means that sometimes English characters confuse them. l, I and 1 can all look alike to them especially in some fonts. Like this one. So I had some non obvious "spelling errors." They and I have a better idea of what to look for next time.

The other one was harder. We’re using C# and Windows Forms. Now normally this makes things easy. But you can also cause some very puzzling errors. In this case, the code seemed to be doing everything it was supposed to do EXCEPT showing the results in a list box. I tried a lot of my bag of tricks. Single stepping through code, displaying intermediate results (that didn’t work because nothing was displaying in the list box). I copied the code into a new project. I created new objects. I tried a lot of things.

Finally, I did a side by side comparison with a project that worked and that showed me the problem. For the curious, Windows Forms projects run a subroutine to initialize and instantiate the objects on the form. Some how, probably a copy paste error, this student was calling it twice. Without going into detail, this resulted in two sets of objects with one of them covering the set that was actually being acted upon for the display.

I try to look on the bright side of things. In this case, I have new things to look for that I didn’t have before, I have gained insight into issues that my international students have (and may change some variable names I use), and I got to demonstrate debugging techniques to some students. That’s a win right?

Tuesday, March 19, 2019

Interesting Links for Computer Science Educators 19 March 2019

I haven’t done one of these for a while. I still Tweet or retweet a lot at @AlfredTwo but I needed a break. I’m not sure I will do this every week but I think I will shoot to do it from time to time.

Microsoft Education posted a bunch of resources on Ways to encourage girls to keep pursuing STEM this Women’s History Month There are some posters I think will show up in my computer lab soon there as well as other helpful links.

David Renton is doing some amazing things with his students who are programming virtual reality applications. Currently he is having Students Build International VR Prototypes for Children This is more than about computing. It is a multi-national effort with some support from Microsoft in the UK and deployment at a hospital in Sweden.


Mike Zamansky has a  great post about Adapting A Nifty Assignment  You may or may not be familiar with the SIGCSE Nifty Assignments sessions, check them out if not, but they are pretty nifty but many of them really do benefit from adaptation to a particular environment.

I found this on the Blog at CACM I don’t know about you but calculating with Roman numerals (what no zero?) was something I wondered about. This article explains it all. I wonder if this might make a nifty project? Calculating With Roman Numerals is Not So Difficult 


Speaking of SIGCSE, Bryan Twarek provides a nice list of K-12 Teacher Takeaways from SIGCSE 2019  on the CSTA Blog. Not as good as being there but Brian includes a bunch of related links.


Under my list of things to keep an eye on, Microsoft had a post called Achieve more with Microsoft Game Stack It looks mostly like a repackaging or rebranding of a number of new and existing resources for game developers. Will it have application for schools? Maybe in game development courses but even there it seems like Game Stack is more for professionals than beginners. But we’ll see if anyone in education takes it on and provides information.

Thursday, March 14, 2019

Awards I Wish We Didn’t Need

Last week my school was told we had earned the College Board’s Female Diversity award for both Advanced Placement Computer Science A and Advanced Placement Computer Science Principles based on how many female students we had in those courses last school year. Yeah!

We’re one of two schools in the state to get this recognition. That’s a bit disappointing. The more I thought about it the more I thought how sad that getting to adequate female representation was so rare that schools were getting special recognition for it. Are there similar awards for other AP courses? Are their awards for schools for getting to Male Diversity numbers in courses were male students are underrepresented? Is that even a thing?

Don’t get me wrong. I am thrilled that we have good representation of female students in our AP CS courses. And I’m not shy about sharing news of the College Board's recognition. 

It’s hard to get solid APCS enrolment period. I teach at a private Catholic school that requires four full years of religion. That has a serious impact on electives. We have even better female representation in our lower level CS courses because we require a full year of CS for graduation. AP CS is going to be an elective so we have to have a good environment to get students to want to fit it in.

With cultural norms the way there are, a lot of female students are encouraged to follow other academic paths. World languages, for example, fit the stereotype and it often feels like that is a more common, if not natural, path for female students. And the boys seem to be less excited about languages.

Our goal at my school is to ensure that all students are comfortable and feel like they belong in computer science courses. We are careful about room decorations. You’ll see women in computing highlighted in posters and bulletin board items for example. I think the most effective effort it that teachers encourage all students, reassure them that they mistakes they make don’t mean they are stupid or incapable, and include projects that are not gender biased. You know, be a good teacher.

For now we all need to make efforts to include a more diverse set of students. And it is nice to be recognized for the success of those efforts. But I’ll tell you, having a diverse group of students is all the reward I really need.

Tuesday, March 12, 2019

High School CS Education: Where Do We Start and Where Do We Go?

There are a number of sets of standards with most based on the CSTA standards (https://www.csteachers.org/general/custom.asp?page=standards) and the K-12 CS Framework (https://k12cs.org/). A lot of really smart people (and me in the case of the framework) worked on them but I've been thinking about creating my own set to use.

Why? Difficult to explain but in large part to get things clear in my own head. What do I see as the concepts and ideas I should be teaching in my high school? How do I want to express my thoughts – the same as the existing standard or will putting them in my own words help me understand them better? An open question.

Now one might think this is easy with the standards already written. But it is more complicated than that. High school is very much in the middle for computer science. We’re not yet college/university but we want students to be prepared for that level of education. At the same time, there is no standard of knowledge that universities are expecting all incoming students to have. That makes their lives difficult but they have been living with that as long as there have been CS courses. It’s leaves us in high school a little more free to determine our own output goals though.

On the other end, there is no standard set of CS knowledge that high schools can expect all students to have. That is especially true for a school like mine that takes in students from over a score of different middle schools and two different states. Like the universities, our curriculum has to start assuming no background at all. Oh sure students are somewhat tech savvy compared to many of their parents but I still spend time teaching how to move files from one folder to another. Being great with Instagram doesn’t translate to computer science knowledge.

We see some students who come in more advanced as well. They may have done a lot of programming in middle school. Many in an enrichment course, a summer program, or FIRST Lego League or some other opportunity. They may even be programming in higher level languages. Can they skip the first course? Sure, as long as we have something more advanced to help them continue to grow and learn. It would be a shame if they were effectively done before high school and spent 4 years forgetting things before university.

As I think about high school computer science curriculum holistically I think about the Computer Science Curricula 2013 (CS2013) document. One key take away for me there was the three levels for university curriculum. Basically it was things all CS departments should offer, a level that all departments should offer “all or almost all”  and electives. For high school I don’t know that I want three levels. Maybe two would be enough. Things that all high school curriculum should offer and electives. Earlier version of the CS Curricula had only two levels. I am not sure there is room in the schedule for three levels in high school. Electives should be offered in schools where there is more room.

I hesitate to specify standard or required or even recommended electives for high schools. Gradually CS, and other subjects, move down from universities but there is no clear vision for what will move down from universities to high schools in the near future.
An other idea I like from the CS 2013 document in the Knowledge Area breakdown of concepts. This sort of breakdown is also included in the CSTA Standards of course. Do I want to come up with my own breakdown or use the CSTA version? I’m undecided.

Seems like a big task and it is. But I really feel like I need an expression of my personal (well researched and thought out) ideas of what should be taught. Anyone else feel like this?

[Note: I was on the CS 2013 ACM/IEEE Task Force and the K12 CS Framework writing team. And I still think I need to think about this stuff.]

Monday, March 11, 2019

Don’t Cross The Data Types

Remember in the first Ghostbusters movie where the ghostbusters are told not to cross the stream of their ghost busting guns? And then at the end they do cross the streams? Mixing data types is like that some times. You really have to know what you are doing when you mix data types.

The Facebook group for AP CS A teachers recently had this Java example:

Can anyone explain why a + b is NaN but a+=b is zero?
int a = 0;
int x = 0, y = 0;
double b = (double)x/y;
System.out.println("a: "+ a);
System.out.println("b: "+ b);
System.out.println("a + b: "+(a+b));
a += b;
System.out.println("a(2): " + a);

//output

a: 0
b: NaN
a + b: NaN
a(2): 0

NaN is not a number and is the result of the divide by zero. You probably shouldn’t do that anyway but it happens. What is interesting here is the different way that (a + b) is handled compared to a += b

a += b does a conversion of b to integer before it does the addition while (a + b) does a conversion of a to double. That explains the different results. Of course if you were to do a = (a + b) you would probably get a compiler complaint. I think. I know you would in C# but I haven’t tried Java yet. FWIW C# also complains about a += b and demands an explicit cast. Different languages and compilers handle these things differently.

So what is the message here? I think the message is that programmers should usually make explicit casts when they mix variable types. Maybe you know what will be cast to what for different variable types and different operations but a) how much do you want to bet you’re right and b) how much to you want to bet that the next person to look at your code will understand what is going on behind the scenes?

Mixing types causes a lot of confusion for beginners. SO does how numbers are stored (some kids never seem to understand that 0.1 is an infinitely repeating fraction in binary and what that means) of course. Encouraging students to cast or at least to be very careful about the types they use and the types they mix is an important lesson.

Friday, March 08, 2019

Making Projects More Interesting With More Data

My students are working on the palindrome project. You probably know it – enter a string and report if it is a palindrome or not. In my case, I have them create a method to “clean” the string by stripping out all of the characters that are not letters and a second method to reverse the string. My goal is practice in creating methods as well as string handling and loops.

It’s always more interesting if the test data is more interesting. There are lots of common palindromes that students are familiar with such as “Madam I’m Adam” and “Race Car” and the ever popular “Mom”, “Dad”, and “Bob.” My favorite is “A man, a Plan, a Canal – Panama” because you can read it dramatically. This week I stumbled on a web site dedicated to palindromes - http://www.palindromelist.net/ There are probably other palindrome related web sites as well.

I’m thinking about supplying a file with lines that are and are not palindromes and having students modify this first program to read the file and report.  More data is better data.

Another idea I have percolating is asking students to write code that creates palindromes. I’m not sure how hard this would be as I’m still thinking about how I would do it. Again, data is important. You want to use real words and ideally the phrase should make sense. Does it have to though? Hum.

I have a dictionary file – a text file with almost 114,000 words in it. I figure that should be useful for something. I keep thinking it would be useful for a lot of interesting projects – things like word games (Boggle, Scrabble, etc.)  or maybe spell checkers.

There are sources of large text files on the internet as well. I have files with the full text of some books (in the public domain of course) and Shakespeare's sonnets. Check out Project Gutenberg which has some 58,000 public domain books

I’m thinking some interesting word and letter count projects are a natural. A lot of the projects that have been presented at the SIGCSE Nifty Assignments session (collected here at http://nifty.stanford.edu/) involve working with data sets of words or text. You all know about the Nifty Projects resource right?

You can also make interesting data. For a long time I have assigned a project that creates driver’s licenses based on name and birthday. New Hampshire recently moved away from this scheme for privacy reasons but it was/is a fun project. I grabbed first and last name data from the Census Bureau (there are other lists) and wrote a program to create a data file of random names and birthdays. I’m toying with assigning something like that as an assignment some day. Making sure the dates exist (no February 30th for example) makes it fun. OK, harder, but harder is fun right?

What sorts/sources of data do you use to make projects more interesting?

Monday, March 04, 2019

Remember The Ladies–And Act

In March of 1776, Abigail Adams wrote to her husband who would be the second US president “I long to hear that you have declared an independency. And, by the way, in the new code of laws which I suppose it will be necessary for you to make, I desire you would remember the ladies and be more generous and favorable to them than your ancestors. Do not put such unlimited power into the hands of the husbands. Remember, all men would be tyrants if they could. If particular care and attention is not paid to the ladies, we are determined to foment a rebellion, and will not hold ourselves bound by any laws in which we have no voice or representation.” [ emphasis mine]

After all this time, we, mostly us men, seem to forget the ladies. Most of us are aware that there is a shortage or at least an imbalance of women in the computing field. It’s men’s fault mostly.  We make it worse when we ignore the efforts and accomplishments on the many wonderful women in our field.

We talk about Ada Lovelace and Grace Hopper but use them as tokens too much of the time. Today there are a number of wonderful groups whose focus is directly on bringing more women and underserved minorities into the computing field. Unfortunately, they don’t get the attention they deserve.

Reshma Saujani, founder and CEO or Girls Who Code gives an important response to this problem with her post Erasing Women in Tech: How 60 Minutes Ignored Women’s Voices, Stories, and Expertise

Now I can hear someone saying, well, yeah, but code.org is doing great work and they are helping girls and young women. Plus the 60 Minutes piece was a good promotion of computing for all. There is some truth to that but it misses a point.

These other great efforts, those that Ms. Saujani names and more need their own recognition. How else are they going to attract the participants, the supporters, the money, and build sustainability if no one knows they are out there? Outstanding programs like these need the sun shown on them so they can grow and thrive.

The truth is that we need some special programs for girls and minorities because the male dominated organizations are still not making them as comfortable as they should. Oh sure some of us are trying. I like to think my classrooms are safe spaces for everyone. I’m sure most of my regular readers feel the same way about their classrooms and computer labs. We may even be right. But we’re not everywhere.

As a community, we in computing have to be more generous and favorable to women than we have in our more recent history. Our future depends on it.