Thought for the Dazed

I've had to give up that Distance Learning course as I was having trouble seeing the teacher.

Flickr
www.flickr.com
RobMiles' items Go to RobMiles' photostream
Twitter
C# Yellow Book

Search entire site
Friday
Oct052012

Hull University ICT Twitter Feed

image

You may not know this, but the Hull University IT Service Desk now has a Twitter feed. Well worth following and they seem to respond to messages pretty quickly too:

https://twitter.com/hulluni_ict

Thursday
Oct042012

Debugging Conditions

IMG_5091_2_3.jpg

We had our first programming lab proper today. Conditions and statements. Great fun. The aim of the exercise is to decide whether or not a given customer can see a movie at your multiplex. The inputs to the program are the age of the customer in years (age), and the number of the movie that the customer wants to see (filmNo). Movie number 1 is Looper (which is apparently quite a good film). In the UK you have to be at least 15 years old to see the film. Quite a few students wrote code like this, which makes very good sense:

if (filmchoice == 1 && age >=15)
            Console.WriteLine("Enjoy the film");

The condition will fire when the customer has chosen film 1 (Looper) and their age is greater than or equal to 15, which is just fine. However some folks then decided to improve the program to add the message that says “You are too young”. And they used the else keyword to achieve this:

if (filmchoice == 1 && age >=15)
      Console.WriteLine("Enjoy the film");
 else 
       Console.WriteLine("Access denied - you are too young");

This seems to make sense, but we now have a problem when we finish off the program. People start being denied access to films when they shouldn’t be. In fact they see lots of denied messages, which is very confusing.

The problem occurs because the program can enter the above statement in one of four states:

  • Film is Looper and age is greater than or equal to 15
  • Film is Looper and age is less than 15
  • Film is not Looper and age is greater than or equal to 15
  • Film is not Looper and age is less than 15

The if condition above will fire if the program is in the very first state (which is what we want if the customer can see Looper) but the else part will fire in all the other three states, leading to “Access denied” messages when we really don’t want them. One way to solve this is to split the program into two tests, so that the age test only takes place once the program has decided that the customer is seeing the Looper film.

Actually, there are lots of ways of addressing this issue. For me the interesting thing is that you need to be careful when you take a tiny piece of code that works fine (the original test) and then add a bit extra to it. Your program must handle all the input possibilities, not just the ones that constitute the “Happy Path”.

Wednesday
Oct032012

The Pi has Landed

DSCF8836.jpg

Raspberry Pi and Raspberry Yoghurt. And a Red Rocket, that looks like it has been Photoshopped on, but did actually fly past as I was taking the picture.

I’ve now got a Raspberry Pi! I got it from Cameron, who also very kindly supplied me with an HDMI to DVI adapter so that I can plug the Pi into a monitor in my office. It fired up a treat after I had built an SD card with a copy of the operating system. Looks very nice and works well. I’m trying very hard to remember all the Unix commands I used to know so that I can drive the thing.  In case you were wondering why I’ve bought a Pi (as if being me wasn’t enough reason), this will be the beating heart of my video game coffee table, which is now taking shape. I even went down to Argos and bought a couple of coffee tables which will be used to hold the monitor and the other gubbins. Tomorrow we are going to have a go at connecting the joysticks to the Pi and try to run a Mame game or too. Should be a fun way to spend a lunch break….

Wednesday
Oct032012

First Rather Useful Seminar

image

We had our first Rather Useful Seminar today. Loads of people turned up. I would have taken your picture folks, but in the excitement of the moment I forgot. I did remember to give away a prize though, the fabled “white rocket of happiness”.

Next week, same time (1:15) and place (Lecture Theatre D) I’ll be giving away another prize. A free copy of my Kinect book. This is actually quite appropriate, as the session is all about Kinect development. I’ll even sign it if you like.

You can find the entire programme of events for the run of Rather Useful Seminars, along with the slide deck for this week’s presentation,  over at www.ratherusefulseminars.com.

Tuesday
Oct022012

Rob at the Round Table

DSCF8830-Edit.jpg 

You can’t say I’m not versatile. A couple of weeks ago it was Cottingham Women’s Institute, tonight it was the local Round Table who had invited me to speak. So, in my smart suit (but not quite as smart as the folks above) I turned up at the Hallmark Hotel to try my hand at after dinner speaking. Or in my case, after apple crumble speaking as I didn’t get there in time to eat the whole meal….

I’ve not done this kind of thing before (I hope this didn’t show too much). I’d carefully prepared some notes that I thought might go down OK, but thanks to SkyDrive not synchronising them properly (can you see a pattern forming here?) I’d not had as much time to work on them as I was planning too.

Anyhoo, thanks to a great audience, who even managed to laugh at quite a few of the the jokes, I made it through around 20 minutes of “not quite as well prepared as it might have been” mayhem. Thanks for inviting me folks. And the apple crumble, to say nothing of the entertainment that followed my talk, was splendid.