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

February, 2012

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Microsoft Developer Day: Entertainment Reimagined

    • 0 Comments

    image



  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Magic Numbers Are Bad

    • 1 Comments

    I had my friend Clint Rutkas review some code of mine. Now I have been writing code longer than Clint has been alive but he’s a very smart guy and he writes more production code than I do these days. He;s written a lot of the Channel 9 projects. He’s famous for his Kinect driven lounge chair for example. Since his code is a lot more public than what I write most of the time he’s pretty careful about best practices so I knew he would be a good reviewer. As it turns out he was able to point out some rookie errors I made. Particularly that I was using “magic numbers.” And I was using them a lot. What is a magic number? It can mean several things and Wikipedia has a whole post on magic numbers. But in this case the following definition explains what I was doing:

    Unique values with unexplained meaning or multiple occurrences which could (preferably) be replaced with named constants

    Why is this bad? The two reasons in this code are one that it introduces multiple points of error and it makes the code hard to understand/support. Since I was using this number in a bunch of places I would have to be very careful not to miss one if I changed things. By using a named constant I could easily make the change in one place and “fix” all occurrences. The second problem is that it is not at all clear what the numbers mean, how they are selected and what happens if you change them. This makes support a real problem. So I need to go back and fix that.

    In fact I need to look at which of those numbers are really constants and which should be calculated based on something. In at least one case the number that is hardwired in is the width of an object. What happens if I change that object? Actually I did and that caused me to change the magic number. This should have been a slap on the head to fix the underlying issue but it wasn’t. Clearly I need to make haste more slowly. Well we live and we learn. The good news is that this will all show up in a future post so hopefully others can learn from my errors.



  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Interesting Links 13 February 2012

    • 0 Comments

    Home again after a week in Texas! Had a great time in Texas both at the TCEA conference and the steering committee meeting for the CS 2013 project. All in all I talked to a lot of people, learned a lot and still managed to get a lot done. Among the things I got done was collecting a lot of links to share with you all. Especially important are a couple of reminders.

    Game Design storyboards for the Imagine Cup are due tomorrow. Wow! How did that happen? Be sure to check out Randy Guthrie’s a long information packed post about Key Imagine Cup 2012 Dates Approaching While some deadlines are 14 February some are in early March. Be sure you don’t miss anything.

    Speaking of not missing things - Rob Miles (@RobMiles) blogged about the  Kinect Fun Labs at Imagine Cup  which also has a deadline coming up. If you know students working with Kinect be sure to let them know about this. Especially let them know that 100 teams get a Kinect. Deadline for Team Formation/Registration and submission of your Kinect Fun Labs Challenge project plan is March 6, 2012 23:59 GMT

    In a connection between the Imagine Cup and the US Forum that Microsoft Partners in Learning runs for innovative educators check out this post about| South LA educator Kinects with Crenshaw High students One of last year’s recognized teachers is working on this year’s forum with students working on the Kinect.

    If you are an innovative teacher Are You Applying for the 2012 US Forum? Check out this video on Microsoft Partners in Learning 2012 Forum. Why Apply? And as you look into this year’s US Forum it is nice to look back on last year's finalists.

    Kodu TeamThe big news from the Kodu team (@koduteam) last week was young Hannah‘s visit to the White House as part of the White House Science Fair. You can watch this video and hear the President ask her "So you want to be a game developer?"   Hannah had the chance to show the President her Kodu game that won her the Kodu Cup last year. Very cool.

    Now a couple of blog posts by other people that I want to recommend.

    .By the way, if you are a Twitter user you may want to look at my list of computer science teachers on Twitter Please let me know if I am missing someone I should have on that list. And follow me on Twitter @AlfredTwo

Page 5 of 8 (24 items) «34567»