Computer Science Teacher
Computer Science Teacher - Thoughts and Information from Alfred Thompson

February, 2011

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    FizzBuzz–A Programming Question


    Projects or exercises that lend themselves to many different “correct” solutions are just about the best sorts of learning experiences I can imagine. They really open the possibilities for discussion and from discussion – questions, answers, explanations – comes real learning. Recently Dennis Shaw, a student at Old Dominion University and a Microsoft Student Partner, told me about the FizzBizz exercise. (see Using FizzBuzz to Find Developers who Grok Coding for where it comes from) This is exactly that sort of multiple solution but not that difficult sort of exercise I love. Briefly stated the exercise is:

    Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.

    So there you have it. It involves using some sort of conditional of course. Nested or unnested? It can be done either way. Which way is best? Do you check for multiples of three first or five? Do you check to see if the number ISN’T one of those cases  first or if it IS one of those cases? Or rather than If statements is there a different way completely? Perhaps a select/case structure? Does creating functions/methods complicate of simplify the result? If students know multiple programming languages is there one that is better for this than another (think especially about functional languages v. procedural languages). Are there special operators (like perhaps the ternary operator in C#, C/C++ and Java) that might make the code “tighter?” Is there a trade off between complication and understanding? Oh and of course, does your solution actually work?

    Justify your answers. (Don’t you just just love the teacher-ness of “justify your answer?” Smile)  I can see asking students to write up an explanation of how their solution works and why they did it that way as a means for forcing examination of the solution. And as a side benefit a lot of students can benefit from yet another writing exercise. Code that can’t be explained isn’t properly understood and that causes problems in the long run. A piece of code should not be “magic” to the person who wrote it.

    There are many solutions on the Internet to the FizzBuzz question. So yes, some student might go searching for one and even try to use it. The “justify your solution” question means that they still have to understand and explain how it works and why they like it. I can’t see a student saying “I like this solution because I found it on the Internet and it works.” Well, I hope they wouldn’t try that. But if they do, grade them on how well they explain the benefits of using borrowed code and if they credited the original source properly. And of course they should also be able to explain why this solution is better than others they might have found. Surely they were not so lazy as to hand in the first solution they found?

    BTW a couple of related posts of mine are Teaching, Learning and the Job Interview and Characteristics of a Good Programming Project

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Are Programming Languages Really Languages


    Every so often someone suggests, sometimes in jest and some times in all seriousness, that programming languages “count” as a language for meeting graduation or degree requirements. According to Ian Bogost, who is not happy about it, some schools are actually doing this and others are close to it. (Computers are Systems, not Languages)

    Is this a good idea? I think it largely depends on what you see as the value in learning a language other than your own native language. As someone who struggled his whole academic career with languages (first year French twice, First year German three times) I’m not so sure that language learning the way we do it in US is much good. Very few really become fluent enough to have more than the most casual of conversations (any one have evidence to the contrary?)  One reason I often heard for learning a foreign language (the politically correct term is world language I think) is that it gives one a better understanding of the culture of the countries where it is spoken. I guess that is true to some extent. Although with our “flat world” is it as necessary as it was a generation or two ago? Arguable. Isn’t the world of computers a culture though? Perhaps learning to program helps people, especially in the humanities, some insights into that “other” culture?

    Another reason I have heard is so that one can read research and other works in the original language. Perhaps that made a lot of sense when French and German were the principal languages of some areas of study. But today people write in far too many languages to make focusing on one make for a solid argument – well unless that language is English. An awful lot is written first in English even by people whose first language is not English. On the other hand there may be some value in being able to read code in the “original” language. It’s a theory. And fortunately computer languages are often enough alike that learning one or two is enough to have a reading familiarity with others.

    Does learning a different language help one understand their own language better? That seems a stronger argument than some others. There is no close corollary to this with programming languages with the possible exception of COBOL. Smile 

    So am I arguing that programming languages should take the place of natural languages as general education requirements. Not really. I’m sort of asking why we have learning natural languages as a requirement. Sacrilege of course but why not? I do think that more people should take some programing or other real computer science course though. It is part of being a fully educated person in the 21st century.

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    18 Monkeys in a Room


    “18 monkeys in a room” is how a friend of mine described the typical high school programming competition. You take a much of kids, usually in groups of three to four, and lock them in a room for X hours and give them Y programming tasks to solve and give awards based on who solves the most in the least amount of time. Not a lot of time for deep thought, careful design, or the creation of really useful programs. Is this any way to see who knows how to program? Maybe, maybe not. But what is the alternative?

    There are longer form competitions of course. There are many high school students competing in the Imagine Cup, though mostly in the IT Challenge and Game Design events. Very few in the Software Design Invitational which takes a longer term view and requires a lot more in the way of design and development.  There is also the Bliink web design competition specifically for high school students. Even still it is very difficult for high school students to compete. They have more classes to take than college students which means no free time during the school day and lots of homework. Plus sports, plus clubs, plus for many students jobs to go to. So time is an issue.  That is why the “18 monkeys in a room” version is the default. It takes less time for students and less effort for judging.

    I would not suggest these competition have no value. I think they do. They promote thinking on ones feet, problem solving under pressure, and are great for bragging rights. And our computing students need to be recognized for what they do. We get what we celebrate in society. The best thing about a programming (or web design) competition is a chance to celebrate kids who are good at computer science.

    But still I wish for some thing in the middle. Some competition that is not just for a day but that requires some long form thinking. Some planning and an outcome with purpose beyond showing off ones mental quickness and skill at tossing a bunch of code together and getting it to work. I’m not at all sure what such a competition would look like. Surely you have an idea? Or is the “18 monkeys in a room” way the best that it can get? Or perhaps we should focus on real long form events knowing that we will only get the few, the crazy, the highly motivated to enter? Come on I need ideas here people!

Page 1 of 7 (20 items) 12345»