Wednesday, November 13, 2019

Not Too Easy and Not Too Hard

We’re covering Classes and Objects in my Programming Honors course this week. Specifically we are learning how to program classes in C# and use them in programs.  The struggle for me is to come up with classes that are interesting to students, practical for them to use, and not overly complicated. This is not Advanced Placement computer science A and we don’t have a whole year for the course.

I start with a simple Dice class. Easy enough as an introduction . I also live coded a Coin class. The difference being that I added images to the coin class to show them that more interesting objects can be used in classes. So what next?

Things I have used in the past include a playing card class. Interestingly enough this has had cultural implications. I have international students who are not always as familiar with American playing cards. But it works. There are a lot of pieces to playing cards and you can do them simply (face value and suit) or complicated (Face value, suit, nominal value – face cards are 10, front and back images, suit color, text names, etc) Methods and constructors can get interesting to say the least. So can creating programs to use the “cards.”

I tried a Pez dispenser class once. I do have a 12 inch Pez dispenser on my desk after all. I’ve done it the simple way with just a capacity value and a current count value. What I would really like to do is use a stack in the Pez dispenser class and have candy objects to put in it. If I were teaching APCS A and had time to cover stacks I would do this for sure. But I don’t.

I’ve thought about revisiting some of the class projects from prior AP courses. Anyone remember BigInt? I kind of liked that one. I did more with the Marine Biology Case Student but my students never really liked it. They called it the DAF – Dumb Ass Fish case study. Both may be a bit much for the time I have though.

I had some fun with a quiz question class last year. Data included the question, an array of possible answers, and an index of the correct answer. I liked that for showing how flexible array parameters could be. A true/false question is just a question with two possible answers. The next design question is of course do you have a simple array of questions or do you design a quiz class? If a quiz class, what does that even look like? Might be fun the have students try that design.

I’m still playing with more ideas. I’ll have to use something tomorrow but maybe the good idea fairy will hit before Monday. Suggestions anyone?

Friday, November 08, 2019

Define Better

Someone posted an interesting question on Facebook.

Is using ++i(pre-increment) better than i++(post-increment) ?

My reply was to ask for a definition of “better.” The Facebook posts have a lot of answers from people who appear to not have written a compiler themselves and who making a lot of assumptions. But the point of this post is not to discuss which option is better for some nebulous definition of “better.” Rather is is to think about asking the question of what do we mean by “better?”

There are a lot of what I call religious arguments in computing. Tabs or spaces, curly braces in columns or have the open on the end of a line, what is the best programming language, and on and on. Most of them stem from differing definitions of “better.”

Sometimes things matter very much at one point in time but not at all later and yet the bias from early days remains. There was a time with memory was so tight that a single character variable name was much preferred to a longer more descriptive name because of the space used. Most of my readers probably don’t remember those days but I do. Fortunately I recognized when the change happened. Not everyone did so quickly.  This is possibly at the heart of some of the tabs vs spaces argument for at least some old timers.

Other issues have become moot or mostly moot because we have so much smarter compilers and interpreters these days. We have long been at the point where compilers write better low level code from high level code than even the best assembly language coders. I seriously doubt that there is a difference between the code generated for ++i or i++ as the incrementor in a for loop these days. Compilers are too smart for that. Compiler writers think long and hard about those sorts of things.

How doubly dimensioned arrays are declared used to make a bigger difference than it does today. I can remember thinking long and hard about how to declare and iterate through two dimensioned arrays. You pretty much had to know how the compiler would allocate memory and what cache would look like to get optimal performance. I don’t think many people think about that today except for the most performance critical applications. Applications we don’t give to beginners anyway. Compilers do a lot of optimization on this sort of process so we don’t have to think much about it. Artificial Intelligence and machine learning (see also AI-assisted Programming) are probably going to make compilers even better than they are today.

Today I think “better” in terms of programming should mean “easier for programmers.” Easier to write, easier to understand, easier to modify, and to allow programmers to think about the end result and not the assembly/machine language generated.  Let the software do what software is good at and people do what people are good at.

Thursday, November 07, 2019

AI-assisted Programming

As I said in yesterday’s blog post,Microsoft has been running their big MSIgnite event this week and making all sorts of announcements. One interesting announcement what improvements to what they call Visual Studio IntelliCode.  The idea is that they are using machine learning to help programmers with writing code. In the latest update are whole line completions and refactoring. Interesting.

I haven’t seen IntelliCode in use before and it is probably because it is not turned on by default. I did some searching and found that it can be turned on as an Extension (I had to search a bit under the Manage Extentions option) and then you can customize aspects of it from Tools –> Options –> IntelliCode. Oh, and you need Visual Studio or VS Code 2019 for this. I am using Visual Studio 2019 Community Edition which is free.

SO far I am not seeing obvious help from it but it may be that I have to do something more complicated in my code or write more code first. It does apparently take context into account for its suggestions and I may not have given it enough yet. But I’ll keep playing. And maybe I should look for some video demos online.

There are other things to think about though regardless of if it has been useful already. What is the training like? The write up I have seen says that it learns from examples on GitHub. Initially that scared me as literally anyone can upload to GitHub. One reference I found said  something about the 500 best repositories on GitHub. What ever that means. And what was the criteria for “500 best?”  What sort of standards will this learning suggest?

Some of the documentation talks about options for using other databases of code to train the system so that businesses can train the AI with their code and standards. As a teacher I wonder if there could be a training set for AP Computer Science A? I think Java is supported with IntelliCode in Visual Studio Code.

No doubt some will complain that it is “too much help” for beginners but I’m not sure about that. You still have to know enough to take or reject suggestions for one thing. And having the computer tell a beginner something like “you should make a method to reduce this redundant code” might be better received than the same comment from a human teacher.

Will this help students learn more or dumb down the process? I’m an optimist and think it will be a good thing. What are your thoughts and concerns?

Wednesday, November 06, 2019

Visual Studio Online–Possibilities for Education?

Microsoft has been running their big MSIgnite event this week and making all sorts of announcements.  One of them was a cloud-based development environment called Visual Studio Online.

OK, that looks interesting and I will probably try it out soon. It may be an answer for people pushed to Chromebooks,  others who are at one to one bring your own device schools, or just want students to wrote programs from home. I wonder how it works on otherwise underpowered older computers?  There is some concern about costs and that is something I need to understand.

Maybe I can find someone with an education focus at Microsoft to explain how it might work cost effectively for schools and students.  Or maybe I can figure it out through all the marketing hype. We’ll see but it sure does look worth looking into in more detail.

Question added later: I wonder if this will let me develop iPhone apps without buying a Mac? Anyone know?

Monday, November 04, 2019

CSTA at 15 #CSTAat15

The Computer Science Teachers Association is now 15 years old. I’ve been a member from the start and I have to say that in some ways it feels like it has always been there but in other ways it feels like it just started.  There was a K-12 computer science education community before CSTA. But it was small and one could easily feel alone. CSTA brought a new sense of community and togetherness. Most of all, perhaps, it brought us organization and a stronger sense of belonging.

There was the CS & IT Conference (now called the CSTA Annual Conference)  before CSTA as well but it didn’t have the same feeling of permanence and sustainability that CSTA brought to it. CSTA brought growth and strength to the conference. It’s been the annual highlight of my professional development for years now. Presenting at several of these conferences has been a huge privilege and honor. And added to my learning as well.

After I left industry some years ago I ran for and won a seat on the CSTA Board. What a wonderful experience those four years were. Hectic as we changed Executive Directors during that time. It was a real time of transition. That wasn’t as smooth as many of us would have liked and I think we experienced some growing pains during those years. We’re on our third ED now but things seem to be well on track. Kudos to the Board (after me) who lead the way through the last couple of years and another ED transition. We have an amazing board at CSTA who work very hard for the membership.

The growth of chapters has been a big part of the CSTA story.  Fairly early on, CSTA developed programs to train and prepare chapter leaders and that has paid off in spades. There are more and stronger chapters than ever before. CSTA is both national AND local and that is important.

CSTA has helped train advocates among teachers and support them locally. CSTA members have advocated, lobbied, pushed, and otherwise promoted CS in their states, counties, school districts, and yes even nationally. Some of the companies and other groups get a lot of credit for the growth in computer science education in the US but the real heroes are individual teachers who alone or with other CSTA members did the ground work to make things happen.

From conferences to board membership to involvement with committees and connections with life long friends CSTA has been an important part of my life. I can’t wait to see what the next fifteen years bring.

Friday, November 01, 2019

Magic 8 Ball and Projects From Real Life

There has been a 12 inch tall Pez dispenser on my desk for a couple of years now. It’s a great visual aid for talking about stacks. Today I got a Magic 8 Ball as well. It turns out that a lot of my students were unfamiliar with this staple toy of my youth. Since I really like using the Magic 8 ball program as a demonstration I decided I really had to get a physical ball.

At this point in the semester we have covered loops and arrays and it is time to make programs more interesting by adding more data. I want to use something that makes sense and is not just a demo without meaning or purpose. Having code you can have some fun with is always a plus as well.

I went to Wikipedia and found the classic 8 ball answers and placed them in a text file. My demo reads the file into an array when the program loads. Once the array is built clicking a button displays a random answer. It’s pretty simple to code and we code it together as a class. Students love asking it questions when we’re done.

Usually I have students add their own answers to the text file and then modify the program to handle the new set of answers. We also talk about different ways this could be coded. What if we didn’t know how many answers/lines were in the file? Would be use a different loop and/or a different array type like an arrrylist? What options (methods or functions) should we use to provide the most flexibility?

This also provides students with some sample code to look at when I assign larger projects and expect them to do much more on their own. Is this a good project? Magic 8 ball says “Yes definitely.”

Friday, October 25, 2019

A Loop By Any Other Name

My first programming language was FORTRAN IV. As I recall we had Do loops. They worked pretty much the same as what we call For loops in most languages today. We didn’t have while loops but we did the same sorts of things with line numbers, if statements, and the powerful but “evil” Go To statement. As time went on I learned more ways of specifying looping constructs including recursion. Recursion took me some time to wrap my head around. Possibly because I used some languages that didn’t even support it back in the day.

These days there are all sorts of iteration loops of various complexity and power. For a software developer that is wonderful. For a teacher? Well, it means you have to make decisions about what to teach. For a one semester, first programming course I like to keep things simple. A C-family For loop has all sorts of possibilities from the simple to some pretty complex structures. Eventually students will learn many of them but I could probably spend half a quarter just on For loops if I tried to get everything possible in and understood. The cognitive load on some possibilities feels like it would be too much for many students.

Mostly I try to focus on the base concepts. A loop has a set up piece. Variables are set to a known starting state. A loop has some sort of comparison it see if it is finished. A counter it checked, a flag is checked, or maybe an interrupt happens. But something has to stop the loop sometime. usually but we can get into those times when an infinite look is useful later. And of course something has to happen that changes the values or states that the loop is checking.

Understanding these concepts will, I sure hope, prepare students for what ever syntax or iteration style they run into over time.

When we teach students for a career rather than just for a job the concepts are much more important than the programming language or the IDE. Concepts – what a concept!