Taking One From The Team

IMG_5551_2_3.jpg

One of the Second Year courses that I help deliver is our Software Development module. As part of that we put our students into teams and get them to write some software for a picky customer. They have to deal with dodgy legacy software and the fun and games that is associated with working as part of a team.

One of the rules that we have is that everyone in a team should write some code. Not all of it, but some of it. One of our worries is that in a team of 6 people we might get a couple of folks who will say “We’re the best programmers here, we should write all the code” and then go ahead and try to do just that. This is bad in many, many ways.

For a start, they might not be the best programmers there, just the ones with the biggest egos/mouths. For another thing, they might not be able to do all the work with just two people. But most importantly, if they are the best programmers around, and they could write all the code they should still not try to do it. Because from a learning outcome point of view they are missing out on a huge opportunity.

If the “great programmers” just churn out the code all they’ve done is reinforce their high opinion of themselves. But if instead they decided to piece out the work sensibly and then spend some of their time mentoring those who are less confident coders so that everyone gets better at development, then they are picking up an incredibly valuable skill. The ability to teach people stuff is really useful, even if you have no intention of going into teaching. When you try to explain something to another person you have to try to put yourself in their position and then find a context which they understand, into which you can put the information you are delivering.

The skill of being able to explain something to another person is very valuable, and it is just the kind of thing that employers are looking for. It also makes you more confident in interview situations, just because you are better at talking to people.

So, don’t think that offering to write all the code is “taking one for the team”. It is more like “taking one from the team”.

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”.

Teaching in “Sometimes Useful Shock Horror"

IMG_7895-Edit.jpg

If any of my students ever want to bring me a completed exam script I’m always happy to “mark” it in front of them. Quite a few take advantage of this and it really helps their grades (folks on 08120 – there’s still time before Thursday)

I’ve spent some time today going through answers and I’ve noticed something that worries me every time I see it. Some of the answers were just about spot on, but didn’t leave me with the impression that the student giving them really knew what they were talking about. It was as if they were just giving responses that they had learned, rather than speaking about something they understood. Now the thing is that this approach probably works fine if you are learning about Kings and Queens of England, but it is very different when we are teaching something that we really want you to apply. A lot of the stuff that we are teaching is intended to be applied to solve problems.

The thing to remember, if you are stuck in this revision thing, is that it is much more sensible to put effort into trying to understand the topic that it is to work really hard just remembering things. I never really got to grips with the piano because I was too “lazy” to learn how to sight read music for my left hand. So I’d just learn the left hand bit in time for the lesson that week. Of course, eventually this technique broke, when I found that the next exam had a “sight reading” test.

Learning to program is like this. You can learn “If a class implements an interface it must contain implementations of all the methods specified in the interface for it to be possible to create an instance of that class”. Or you can work out that we have interfaces so that we can build systems that deal with objects in terms of what behaviours they have (these are the methods specified in the interface) rather than the class hierarchy that they are part of.

Knowing the former will get you half the marks in the exam. Knowing the latter will let you create a mechanism whereby all the objects in your solution, the receipts, customer records, addresses, invoices and product descriptions, can be sent to a printing process that just asks them to print, and doesn’t care what type of object they really are because all the objects implement the iPrint interface which contains a “PrintToPaper” method.

If you want me to go through any of this stuff please come and see me and I’ll be happy to do just that. You can also post questions on the forum, and use the Twitter tag #08120Revision for quick questions. And don’t forget that we are not telling you this stuff so you can reflect it back to us in exam answers, we are telling you this stuff so you can use it to make things work.

I always find it amusing when students come back to me after a while on the course and say “That thing you taught us, turns out it is actually useful”.

Well, duh.

Think of the User

DSCF2723-Edit.jpg

I’ve jut spent the day in the programming labs looking at first year work. When I go to bed I will not be counting sheep, but Sweepy Cleaner games and Bank applications.

Some of the work was astonishingly good. One thing I did notice though was quite often the applications (I’m thinking mainly bank here) were a bit hard to use. Sometimes to achieve an action you had to move to a menu, type something in, press a button, click a confirm dialog and then click another dialog to acknowledge a message that you’d done the task. I often made the point that if there were 1,000 bank accounts to be entered these actions would add up pretty quickly and lead to a bunch of very unhappy users.

If you are making anything with a user interface you must show it to some users. Saying “I did it this way because I thought it would work the best” is not really a recipe for success. Getting someone to use it, or using it yourself for a few transactions will quickly bring home whether or not an application is easy to use.

Codeacademy for learning JavaScript

DSCF6379.jpg

During a First Year lecture this week I said that the students should spend some time this Easter learning JavaScript. Everyone should know a bit of JavaScript, it is what makes web sites work, and with the coming of HTML 5 it will be even more important. I’ve just found a really good way to learn it too. (this also works for anyone who fancies doing a bit of programming). Take a look at Codeacademy.

http://www.codecademy.com

Looks like great fun.

Dragon for a day

image

- what would you do with this?

I got to be a dragon today. For a little while. Elliot, one of our final year students, is doing one a module which is all about teaching computing in schools. He had the neat idea of asking Emma to show our HIVE Immersive Visualisation Suite to his group and then getting them to pitch business plans based on the technology they’d seen.

And he needed some dragons for the pupils to pitch to. Which is where I came in. So today we got to see the presentations.

Most impressive. Virtual golf on a cruise ship, using motion capture to sell fashion, 3D mapping for fire safety and the winner, an immersive take on driving lessons.

All presented with enthusiasm and not a little business acumen. To say that this was probably the first time these folks had presented to an audience in this way they did a very impressive job. As I said at the time, make sure that when you are telling people the things that you have done you mention you’ve done stuff like this. Great stuff.

Tutorials, Objects and References

Snowy Library.jpg

We are doing objects and references in the First Year tutorial today. Great fun. Well, at least I thought so. I asked the class whether big objects in memory have larger references than small ones. They don’t – the size of the tag is always the same – no matter what it is connected to. I went on to explain that a reference tag contains a bunch of information about the thing it is referring to, including the type that it has, for example string, BankAccount, AlienSprite or whatever class you have created.

Then someone asked a great question: “What happens if the type has a very long name? Does the reference tag get bigger?”. Aha! What a great question. The answer is no. This is because the type of a reference is managed in terms of a reference from the tag to the type object that describes that reference. In other words, a reference to a BankAccount will also contain a reference to an object that describes the BankAccount class.

I was very pleased with this question, because it let me start to explain how, by using objects, you can build up structures of data that are genuinely useful. I’ve been explaining structures and objects all week and several times I’ve had the sensible question “What’s the point of objects and references? They just seem to make life harder for us.”  This little allows me to show how easy it is to use references to allow the system running the program to track and mange the type of the objects it is using.

I reckon that a good tutorial is when the students learn something. A great tutorial is when the tutor learns something as well. I’ve now got a lovely new example to use next year…

Hash Tag Revision

Chimneys

I said that anyone revising the Software Development exam could tweet their question with the tag #08220revison and I’d answer as best I could. Here are some of the answers. Good luck in the exam folks.

Multiplicity: A library can have lots of books. The multiplicity is one library to 1 to many books.

When to pick the programming language: Analysis should be all about the problem, so the language should be picked in the Design stage.

Waterfall vs. Rapid Development: Waterfall: do each stage, move on and don't go back. Rapid: Keep iterating and adding functionality.

Coupling and Cohesion: Coupling I ask you to do things. If you change what you do, I'm in trouble. Cohesion I can do my thing without asking you anything

Stakeholder: anyone who has an interest in the system(put up the money, wrote it, uses it, gets fired if it fails etc)

Marking Evil Squash

evilsquash Logo
This is a much better logo than my version. Thanks Jamie

I’ve spent the last three and a bit days in the lab marking first year student work. And it has been great fun. There were four of us down there watching students go through 15 minute presentations of their Evil Squash implementations. For those of you who haven’t heard of it, Evil Squash is a board game for up to 4 players. It is a kind of cross between Snakes & Ladders and Ludo. We invented it just for the practical session and we are going to invent another one next year.

Our first year students had to create a program that implemented the game, getting all the arrows on the board to work, along with the “Squash” behaviour that is triggered when one player lands on top of another. We provided a “special” dice sequence which allowed us to test all the game actions and we watched each program run through this. Then we took a look at the code, gave marks for style and any extras (some students added AI players who could take on their human counterparts), checked on user documentation and test reports and finally gave out a mark.

We always do a game development for the first year course, but this is the first time we’ve used a brand new game of our own devising. It has worked rather well. Everyone got into the spirit of the development and we have seen some very impressive implementations of the game, including a few Windows Phone versions in Silverlight and XNA. Expect to find Evil Squash in the Windows Phone marketplace soon.

Once nice side-effect of using an original game was that there was no code out there for people try and use. When people get into trouble with a development there is sometimes a tendency to leap onto a search engine and look for code that solves the problem. This is never a good thing to do. A lot of code out there is buggy and hard to understand and often takes you further away from where you want to be. During the marking we ask for bits of the code to be explained to us, and I found that for the ones I marked everybody knew how their code worked. Even those unlucky souls who hit bugs during the presentation were able to say “Aha! I know what is wrong and how to fix it” and point to the code block that was causing the problem. 

We saw some great work, and gave some great marks out. I’m really looking forward to what they turn out next semester.

Evil Squash Week

SquashBoard

If you show this picture to one of our First Year students they’ll probably start muttering under their breath. That’s because we’re entering the final week of “Evil Squash” coursework. This is my little board game which we are all trying to make workable versions of. You can find out more at www.evilsquash.com We we are going to put the best ones out there on Windows Phone. And there are some really good ones too.

Programming Humans with Evil Squash

Main Board Hi Res

I’m gaining a new respect for board game designers. It turns out to be quite difficult to create rules for the games that are unambiguous and easy to understand. Even what I thought was a simple game, Evil Squash, has turned out to have some nasty edge conditions that we have had to think quite hard about.

Of course, a game design is really a “program for humans”. It is a sequence of instructions that involve the processing of data, with decisions and outcomes. The tricky part is that the rules are written in English, which is a language in which it is very hard to make yourself completely clear.

Perhaps as an introduction to programming we could get a bunch of people to design the rules for a game of some kind, and then “debug” it by playing the game. I’m certainly going to invent a new “imaginary” game for each first year programming course from now on, just exploring the rules and getting students to think about how they work has given a nice new dimension to the coursework.

You can find out more about the game itself at www.evilsquash.com.

Building a Robot Army

DSCF5252

Spent some time this morning building robots. Actually I didn’t, students on a hardware interfacing course did all the hard work. They are all Fez Micro Framework powered and great fun. They are based on the same platform as Oscar, who has been all over the place with me over the last couple of years.

Next week we are going to get some C# code into them and get them running around the desks and not falling off the edge. Then we are going to get another Micro Framework board running and see if we can control them via the internet.

Great fun.

The Best Way to Write Programs

Main Board Hi Res

So, how would you represent the arrows?

The Software Development for the First Year C# Programming course this year is a game I have invented. I’ve called it Evil Squash. It even has its own web site:

www.evilsquash.com

The game is very like Snakes and Ladders, but with a twist that makes it a bit like Ludo as well. At the moment we are working on the player movement, which uses a board like the one above. When a player lands on the tail of an arrow they must then follow it to the destination. We have decided that there are three ways that you can implement this behaviour.

  • A whole bunch of conditions that hard wires the arrows into the program
  • An array with a location for each square that provides a redirection to the destination square.
  • An array of “redirects” that holds the behaviour of the 10 arrows

You might want to consider which is the “best” one. To me, the answer is “you can’t say”. Each of them has advantages and disadvantages. Some of them use less memory, some go quicker. Some are easier to test and some are easier to understand.

One of the things that we try very hard to do in the programming course is to get people to think that often there is no “best” way to solve a problem, merely ones that are better than others against certain criteria. We give extra marks to students who manage to use arrays (I’ve nothing against hard wiring the arrows, but I thing showing you can use an array is something that should be rewarded).

Next week we are going to get the player and the “Evil Squash” behaviour sorted, on the way to making a complete game and maybe even some AI powered opponents.

I’m keeping the domain in case we get some good ones (maybe even phone based) that we might want to distribute.

Smart Students

DSCF3619

We have some very smart students. In C# we are considering problems you can have with conditions if you are checking for valid entries, for example:

if ( flimNo < 1 && filmNo > 5 )
{
// unlikely we will get here
}
else
{

// funny how this part always gets obeyed...

}

I made the point that a number which is less than one and greater than five is pretty much impossible. Quick as a flash, one of our First Years said “Root 36”. Which can be -6 or 6.

FYI, what you really want if you want to reject invalid entries is to change that && (and) to || (or).

if ( flimNo < 1 || filmNo > 5 )
{
// film number is invalid
}
else
{
// film number is valid
}

Open Day Woo Hoo

Complete Audience

This was a great audience. I even had folks going “Woo Hoo” whenever I said robmiles.com….

We had our first University Open day on campus today. Great fun and an amazing turnout. By the time I started talking we had the whole lecture theatre full. Thanks so much for coming, I hope that the trip was worth it. Sorry about the jokes…

Anyhoo, if you did come – or if you didn’t – here are some useful links

www.csharpcourse.com will take you to the C# Yellow Book pages. You can download our complete First Year text from there as a PDF. Come to Hull on an admissions visit and we’ll give you a printed copy.

www.destructiongolf.com is the site for our first 24 hour programming competition. It includes a link to the 360 magazine article that was written about the event.

www.threethinggame.com is the site for our second competition. This includes videos from all the teams about their entries.

www.wherewouldyouthink.com is the site for admissions, I’ll be updating this soon with departmental news and other stuff.

Teaching and Partying at Hull

Did a 13 hour day today. And reminded myself why I love this job. Bunch of teaching on our new hardware modules, then a first year lecture, then a slew of project meetings, then the Postgraduate Party. This was another quiz and video game frenzy which kept me at work until 9:30 pm, but was great fun. Thanks to the Systems team for setting up both parties with speed and efficiency and to Simon for the scary picture quiz that has now got to be an annual feature.

DSCF4069

The winning team with their big box of sweetsDSCF4071

These guys came second. DSCF4073

These guys got to take away the coveted “White Chocolate Bar of Power”.

Another big day tomorrow.

Giving Away C# Books

WP_000314

The lab before we started. Apparently we’ve replaced over half the machines over summer…

Today was the first programming lab. Great fun. All the students turned up and were given a memory key (for files) and a copy of the Yellow Book for 2011-2012 (How quickly the years go by). If you want an electronic copy you can head over to www.csharpcourse.com for a PDF.

WP_000313

Trust me, in real life it is actually very yellow indeed.

My favourite moment in the lab was when a student asked me a question and I didn’t know the answer. “Can’t you tell me roughly"?” he enquired “I don’t know.” I said in my best gravelly voice.

Welcome to Hull.

Welcome to the First Year

First Year

Most of our new students, and Mike Brayshaw in the Large Lecture Theatre.

We did our first First Year lecture today. If you see what I mean. Went well (at least I thought so). Then on to the welcome party. We had Kinect, PS Move, Rock Band and of course Wii Sports. Along with the quiz. Thanks to Simon for the picture rounds.

Puzzle Solving

Doing the quiz

DSCF3823

The Winning Team looking mostly pleased with themselves…

DSCF3828

A good night, well spent.

I’ve put a bunch more pictures on Flickr, you can find them here.