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

June, 2010

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    A Rose is a Rose


    Let me think out loud here a little and get some opinions. On what? On how far to go when naming things in programs. let me start at the beginning. The other day I decided to code up a game of “Rock Paper Scissors.” Perhaps latter to develop into the more geeky “Rock Paper Scissors Lizard Spock.” I’m doing this as a demo of the Select/Case structure in Visual Basic and the switch/case structure in C# along with a little compound if/then/else stuff. It’s a common enough project and simple enough that when I started I let the default object names stand.

    I mean after all how hard is it to remember that RadioButton1 is the option for Rock, RadioButton2 is the option for Paper, and RadioButton3 is the option for Scissors? Actually not to bad. But what number value stands for the computer picking each of those options? And I wanted to select a number to represent the outcome of the comparison to make displaying the result. OK so if RadioButton1 is the player picking Rock then 1 is the computer picking 1. Right? Ah, but then I have to set the minimum as well as maximum because otherwise I have to remember to subtract 1 so that radioButon1 and 0 sort of go together. Ah, forget about it I don’t want to think that hard – rename the silly radio buttons. So now they are rRock, rPaper and rScissors. This gives me something simple that looks like (in part):

    Select Case computerChoice
        Case 0          '   Rock
            If rPaper.Checked Then
                Stat = 2    '   Lose
            ElseIf rSissors.Checked Then
                Stat = 1    '   Win
                Stat = 0    '   Tie
            End If


    That’s the VB code of course. But then I thought, I can use enums in C# and maybe that would be easier. So I created enums for both the computer pick and the result.

    enum whoWins { iTie, iWin, iLose };
    enum iPic {Rock, PaperS, Scissors};


    The code (in C#) now looks something like:

    switch (computerSelects)
        case (int)iPic.Rock:                    //   Rock
            if (rPaper.Checked)
                Stat = (int)whoWins.iLose;      //   Lose
            else if (rScissors.Checked)
                Stat = (int)whoWins.iWin;       //   Win
                Stat = (int)whoWins.iTie;       //   Tie


    It’s all very well self documented and it’s pretty clear what is going on but it feels ugly to me. It’s the conversion/casting that bugs me the most as that just feels wrong to me. How about using integer constants? It’s a little more setup (in VB)

    Dim iWin As Integer = 1
    Dim iLose As Integer = 2
    Dim iTie As Integer = 0
    Dim pickRock As Integer = 0
    Dim pickPaper As Integer = 1
    Dim pickScissors As Integer = 2

    But the resulting code feels cleaner  to me.

    Case pickRock          '   Rock
        If rPaper.Checked Then
            Stat = iLose    '   Lose
        ElseIf rSissors.Checked Then
            Stat = iWin    '   Win
            Stat = iTie    '   Tie
        End If


    For this type of project I think I get all the benefits I want from named objects (in this case integers) in terms of the code being self-documented and requiring less actual thought on things that I really shouldn’t be wasting brain cells thinking about but without the complexity of having to fully specify and cast the enums into integers. Is it still overkill? I could see some people saying so but for me there is enough added value to make it worthwhile. Clearly the computer and the compilers really don’t care. Names are just identification and in many cases they will replace variable references with loading constants into registers to speed. We really don’t need to worry too much about that.

    What do you think? Hopefully I didn’t lose anyone switching between C# and VB but honestly that’s the way my crazy mind works. how would you handle this sort of thing? Is it a worthwhile conversation to have with beginners? Obviously I think so but am I wasting time?

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    A Show About Computer Programming


    One of the things that comes up in conversation when ever getting more students, especially women, interested in computer science comes up is that we need a TV show that would show the field in a good light. People mention how CSI has gotten students interested in forensics for example. The closest thing we have in computer science is NUMB3RS and the star there is really a mathematician. I’ve been giving a TV show about computer scientists or programmers or related some thought lately on some longish drives. I see a couple of possibilities.

    One is a reality show. Think The Apprentice or Top Chef and the like. What would it look like? I see two teams of hotshot programmers who are assigned a coding project each “week.” Perhaps a casual game. Or a phone application for a specific business problem. Or maybe a scientific data analysis project. Something that a small team can do in a reasonable time. Not easy because it has to be non trivial but yet still handle able. Each team would work with a customer and at the end of  the projects they would be evaluated for things like ease of use, meeting the customer’s needs, reliability, etc. The losing team would have to pick two people who would be evaluated with one of them being dropped. Teams would vote people off based on poor coding practices, lack of teamwork or communication, and other issues.

    What would you show? Brainstorming and designing sessions, pairs working at computers (team programming seems like it would work in this environment), progress meetings, user interface mock-ups , customer discussions, demos and the like. We need a mix of people – men, women, personalities, races, etc. It has to show all sorts of people.

    Another is a scripted show. Comedy is fine but let’s not have too many characters like those on the “Big Bang Theory” please! And of course the women should be smart and no one should be ugly. Well maybe one guy but most shows use good looking people and there sure are a lot of them in the computer industry. No really! Drama would also be cool. Tight deadlines, customers changing specifications, differing development philosophies, are all fair game. But can we show people having real lives as well? I know people who ski, snowboard, do wood work (even some serious carpenters), musicians (lots of those) and other people who engage in all sorts of activities that are not associated with geeks and nerds.

    What other ideas do you have? Who would you see cast in these sorts of show? Would they make a difference in attracting young people to the field?

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Critical Thinking


    Friday is not the day to talk about thinking. I think a lot of people in general and students in particular are looking to stop thinking right about now. But critical thinking skills are something I feel is really important so when I learned today that Microsoft has a bunch of resources for teaching critical thinking including a free e-book it seemed worth a blog post of its own. (Note that this is only the latest of a series of Teacher Guides for use in the classroom from Microsoft Education)

    [Microsoft] developed this critical thinking and web research curriculum with the International Society for Technology in Education (ISTE).

    Lesson plans include prerequisites, rationale, essential concepts, and descriptions of related National Educational Technology Standards (NETS) and are designed for beginner, intermediate, or advanced levels, aimed at middle school and secondary students.


    Students have more information at their fingertips than ever before, yet the challenge remains for them to find, evaluate, and apply the information they discover in the classroom and beyond.

    Applying critical thinking skills through web research can help students:

    • Improve search skills.
    • Evaluate the information they find.
    • Incorporate them in their work.

    Explore the ready-to-use curriculum below, including detailed lesson plans, student worksheets, and class demonstrations on:

    • Mechanics of searching
    • Validity and reliability
    • Plagiarism
    • Citing web sources
    • Civil discourse

    Download the Critical Thinking e-book

Page 1 of 6 (17 items) 12345»