Never Apologise in Advance

University Panorama

Over the years I’ve watched loads of presentations all over the place from students, professionals and even once, by mistake, from me on Channel 9. And one thing that has struck me is that there is one thing you must never, ever, do in front of an audience. And that is apologise in advance. If you say at the start of your talk “I’m sorry, but because I’ve not had time to prepare/got drunk last night/just ended an unhappy love affair (delete where applicable) this is is not going to be as good as it might be” then your audience is instantly expecting you to fail, and they will set their expectations appropriately.

Now this goes against a certain aspect of “Britishness” which is that we from the UK should at all times to be slightly self-effacing and modest. If a Brit tells you that something they have done is “quite good” then be prepared for something truly amazing. But you would never anyone from the ‘states saying that something is quite good. In America things start at “awesome” and then go up from there.

I’m not saying that you should attempt to deceive your audience, or that you shouldn’t apologise if something stops you from doing a good job during the presentation. What I’m saying is that you should not set the wrong expectations at the start. I’ve seen some superb talks from people who have come off the stage and told me how badly they thought it went. I’ve also done what I thought were barnstorming presentations to get a decidedly ho-hum reaction from the audience.

If you are not sure about something, say so during the presentation not at the start. If you put a downer on things right at the beginning you are not actually doing yourself any kind of favour.

In the Reserves

Thwaite Cactus Heart

I was a “Reserve Invigilator” today. This means that you get to sit by the phone in your office waiting to get called in to an exam. Fortunately everybody turned up, and so I was able to get on with some more lovely marking.

My “Revision Tweets” do seem to have had some effect, in that I’m getting answers to some of the questions that seem to have been based on what I said, which is nice. I’ve noticed that students make much less use of things like forums these days, perhaps Twitter is the way to go with this.

08249 Robot Fun and Games

08249 Crew

These are the first ever cohort on our 08249 Electronics and Interfacing module. On the left we have the controller team, on the right we have the robot team. Today they got together to link their two .NET Micro Framework programs together so that the controller could send the robot off to traverse a room and measure the size of it. The packet of cigarettes that you see near the robot is actually a really important part of the setup. This is what they stood the robot on to make sure that it didn’t jump off the desk and run away when they were testing the motor code…

It was very interesting to watch the two teams work together as they developed a communications protocol and then implemented it at each end. By the time they had finished they the two devices passing messages backwards and forwards and actually understanding what was going on.

Great fun. Next we are are going to have around 27 or so students on this module. Time to buy a few more robots methinks.

Making Great Games

100 Camera in 1

I’ve spent pretty much the entire day marking. I’m now giving grades to everything I see. I’ve been impressed with what our students have been getting up to this year, it always surprises me how many different takes you can get on the same problem. This year we were making Breakout. Many of the games that they made were good enough to go to market. Some have had really poor presentation but fantastic gameplay. Others went the other way, with lovely graphics but nothing worth playing. Some thoughts for game writers:

Get someone else to play. You might spend so much time admiring your scrolly graphics and particle effects that you forget that it has to be fun. Get other folks to play. You know you are on a winner when you find people playing who become better at your game than you are. And won’t let you back onto the machine to work on it.

Embrace serendipity. Some of the games had really strange collision behaviour that I’m sure wasn’t intentional. Their ball careered through bricks in really odd ways. However, this made the gameplay much more interesting than some of the better behaved ones. If this sounds like some folks got more marks for writing imperfect code I must add at this point we weren’t marking gameplay as such, this was strictly a programming exercise. But it did bring home to me that if something strange happens you should investigate what is going on and not always fix it. Sometimes these things make good features.

Give the player control. Some games had fantastic graphics, sound, etc etc but the ball always bounced the same way off the paddle. Boring. Other games had very poor graphics but amazing ball and paddle interaction that really let you aim at things on the screen. Much more fun. Consider what happens at your average game of table tennis in real life. Not much happening graphically, but a fantastic range of shots available from a simple ball and bat combination.

Put the graphics on after the gameplay is sorted. In real life game developers often use empty “placeholder” graphics when building the game. This forces them to think about gameplay first. No amount of graphics will compensate for poor gameplay. So get the gameplay right before anything else, and then use the graphics to add value afterwards.

Enjoy your games. I got the feeling from many of the games that the students had really enjoyed writing them. There were little touches and flourishes that you would only add if you were really having fun writing the code. This is great, and just how it should be.

Why the New Guy Can’t Code

 

Whitby town

There’s an interesting post on Tech Crunch – Why the New Guy Can’t Code.  (Found out about it via Alfred’s blog). The Tech Crunch post is bemoaning the fact that companies which are supposed to have well managed recruitment processes are ending up with programmers who can’t actually write programs. This is becoming quite an issue in a world which is short of good developers at the moment.

In the past some companies (notably Microsoft and Google) became famous for asking interview questions like “How would you move Mount Fuji? or Why are manhole covers round?”. Their argument was that they wanted smart people, and questions like this will allow a smart person to shine. A tip: I think that in these situations they are interested in what you do when confronted with the question, not whether your answer is actually correct. If you say “I dunno” when asked how to move a mountain, this won’t go well. If you start making plans involving earth moving equipment and calculating volumes of rock then this might go down a bit better. Me, I’d suggest just changing the road signs, but perhaps this is because I have difficultly taking these questions seriously.

Google have apparently taken this a bit further, and now ask for answers to programming questions like “Write me a binary search”. This sounds more technical, but nobody writes that kind of search any more, and the fact you can trot out an algorithm like this doesn’t necessarily prove a lot.

Anyhoo, according to the blog post the trend now is moving towards making an applicant show off what they have made. In other words, the best way to see if a person can program is to look at a program they have made. Well, duh. In the old days you had this idea of an “apprentice piece” that was made by an apprentice at the end of their training to prove their worth. A cabinet maker would create a small wooden box, etc etc, and then show this off to potential employers.

I’ve just spent four days in the labs getting our first year students to show us what they have made. This is the second time we’ve done this marathon effort, and it was nice to see the improvements. Lots of students who last time failed to deliver all the components, or added extras that weren’t needed or worth extra marks, had really focused on the specification and made darned sure that all the important bits were present. And they got very good marks as a result. The students also had the experience of someone looking at their code and asking them to explain it.

I’ll tell any student who listens that they need to get some code out there in the form of an application or game, and be prepared to talk about it when you get interviewed. And if they don’t bring it up, make sure that you do:

“Any Questions Mr. Miles?”
”Yes – do you want to see this game I’ve written? It’s called Cheese Lander”
(sound of minor chord playing in the background)

In all seriousness, if you want to get ahead (or perhaps anywhere) in this business I think that you really do need to have an “apprentice piece” of your own, that you can show off. It is good to see that those hiring are starting to take a proper level of interest in such things.

Marking Time

Humber Bridge South Bank

Spent the day marking First Year programming work. That’s around 15 different Breakout games and 5 or so banks (I got to do lots of games for some reason). I’m getting pretty good at paddle control, which is nice. We’ll finish tomorrow.

One thing that is impressing me is how much more the students are focusing on the deliverables. Last time we did this we had lots of submissions with bits missing. This time everybody seems to have read the specification and figured out just what they need to do. I think this is a really good development. Programmers are legendary for “drifting” off the original design, and it is nice to see some attention being paid to delivering what the customer needs.

Static on the Radio

HypnoCube2

I was doing a C# revision lecture yesterday and I was talking about static class members. I mentioned the fact that every year some students write “Static means that the value of the variable cannot be changed” in the exam, which produces an anguished cry from me and zero marks. I was trying to think of a better way to explain what static really means. And I thought about the radio. If you turn on your am radio and tune it away from a station you will hear static. And that static hiss is always there. It has been there since before radios were invented and it will be there until the universe cools right down. Static class members are a bit like this. They are always there. They exist whether you make an instance of the class or not. Static in this situation doesn’t mean “can’t change” it means “always there”.

We use them in programs when we want a data member that is part of a class but not part of each instance. For example, in a bank we might have loads of accounts, but the minimum amount you can withdraw, the maximum size of the balance we can have and the minimum age for an account holder are all relevant to accounts, but not stored in each account instance. Static works well in this situation.

Three Thing Game Judging Videos

Platform Expo

If you want to see what the teams came up with at the end of the game event, and how well students can function after sleep deprivation and lots of caffeine and sugar, then they are all now available on youtube. Just search for threethinggame These videos are in High Definition, as I’m sure you will spot.

We had Paul Ross from Criterion Games here today (they are the studio behind titles such as Burnout) to give a talk on game development and chat with our students. This was the cue for lots of scrambling for Windows Phone devices so that some of our team members could show him the things they had made during the competition. By all accounts he was very impressed, which is nice.

Anyone who missed out on taking part in the competition this time round needn’t worry. Three Thing Game will be back next semester.

Programming Puzzler

Quick test for all you programming experts. Will this stupid code compile?

public int InfiniteLoop()
{
    while (true)
    {
        Console.WriteLine("Loopy");
        System.Threading.Thread.Sleep(1000);
    }
}

Note: All the namespaces are in place and the WriteLine and the Sleep are perfectly legal calls.

Reference and Value Types

IC 2007 Fri Trip f10 124

 

I reckon that the day I give a lecture and don’t learn anything is the day that I will give up teaching. I always take something away from a lecture, although sometimes it is only a decision not to use that particular joke again…

Today I was telling the first year about reference and value types in C# and I learnt something as well. For those of you who are not familiar with programming in C# (and why should you be?)  this is all about how data is held in a program.

Once you get beyond programs that do simple sums you find yourself with a need to lump data together. This happens as soon as you have to do some work in the Real World™. For example, you might be creating an account management system for a customer and so you will need to have a way of holding information about a particular customer account. This will include the name of the customer, their address and their account balance, amongst other things.

Fortunately C# lets you design objects that can contain these items, for example a string for the name, a number for the balance, a string for the address and so on.  In fact, C# provides two ways that you can lump data together. One of these is called a struct (short for structure) and the other is called a class (short for class). These two can be hard to tell apart, in that the way that they are created is exactly the same. But they have one very important difference. Structures are managed by value, but classes are managed by reference.

Today is the point in the course where I have to explain the difference between the two.  I’ve got a routine for doing this which I’ve used in the past, and it usually gets there. If an item is managed by value (for example a struct) you can think of it as a box with a name painted on it.  If we move data between two variables managed by value:

destination= source;

- the result is that whatever value is in the source box is copied into the destination box. If my source is a structure value which contains lots of elements all of these are copied into the destination. This is how simple variables such as integers and floating point values are managed.

However, if an item is managed by reference the effect of the assignment above is different. You can think of a reference as a named tag which is tied to an object in memory. If I assign one reference to another:

destination = source;

- the result of this is that both reference tags are now tied to the same object in memory.  No data is actually copied anywhere.

At this point in the explanation I usually have a room full of people wondering why we bother with references. They just seems to be an added piece of confusion. Now that we have references we have the potential for problems when the equals behaviour doesn’t do what we expect.  Why do we have these two ways of working with data? Why can’t we just use values for everything?

My answer to this is that using references allows us to provide different views of data. If I have a list of customers that I want to order by both customer name and account number then this is not possible with a single array of values. But if I use references it is much easier. I can have a list of references which is ordered by name and another list ordered by account number.

So far I’m going by the slides. But then it occurred to me to go a bit further, and think about the use of reference and value types from a design point of view. If I’m designing a data structure for a  sprite in a game (for example a single alien in a Space Invaders game) the sprite will have to contain the image to be used to draw the sprite and the position of the sprite on the screen. I posed the question which of these two elements should be managed by value and which by reference.

After some discussion we came to the conclusion that it is best if the image to be used to draw the sprite is managed by reference. That means that a number of sprites can hold references to the same sprite design. You see this a lot in computer games, where a game has multiple identical elements (soldiers, cars, spaceships etc) it is often the case that they are all sharing a single graphic. However the position of the sprite on the screen is a value that should be unique to each sprite, we are never going to want to share this, and so the position should be a value type.

We then went through a bunch of other situations where an object contains things, and pondered for each thing whether it should be managed by value or by reference. Generally speaking we came to the conclusion that anything you want to share should be managed by reference, but stuff that is unique to you should be a value.

Of course references bring a lot of other benefits too, which we will explore in the next few weeks, but the thing I learnt was that the more you can show a context in which a particular language characteristic is applicable the more chance you have of getting the message across.

As a little puzzle, one thing we talked about was the storage of the address of a customer in our account database. Should that be managed by value or reference, and why?

Free Windows Phone Developer Event Next Week

alt

Coming to a cinema near you. Probably.

Hot on the heels of the Windows Phone 7 Live training that we did last week in Bellevue,  Andy and myself will be presenting at a Developer, Developer Developer (DDD) event in Manchester next week on Thursday 7th October (seems appropriate).

If you want to find out how to get started with Windows Phone then come along to the free day’s worth of training. I’ll be doing two sessions on XNA for Windows Phone. I’ll also be telling the jokes that I wasn’t able to use in the Live Broadcasts…. Should be fun.

You can sign up here.

iPhone Game Development Lecture

4435022966

One of our ex students (I only know him as @orta!) is giving an iPhone development talk in the department on Wed, March 17, 3:15pm in Lecture Theatre A in the Robert Blackburn Building. He has had his iPhone apps published (and even featured in Apple commercials) and so it should be well worth turning up.

XNA at St Bede’s College

4407253792

4406491303

A good audience. (If you want to see a larger version of this picture, or to see the other  one I took, click on the images to get to my Flickr pages.)

I did  a talk at a college today. Not done one for a while so I was a little rusty. Fortunately I had a great audience and ended up really enjoying the visit. Thanks to the college for inviting us and to Dr Keith Porteous for giving such a good talk before mine.  I’ve put all the resources on the blog if you want to take a look:

You can find more links to XNA resources, along with my XNA ScreenCasts here: http://verysillygames.com/

Kodu Rocks

Daisies

I must admit I was a bit underwhelmed when I first saw Kodu. At first glimpse I couldn’t see how it would help to teach people how to program.

It turns out that this is because it is not really a teaching tool as such.   The point that I seemed to miss was that the intention was to put people in touch with the experience of making a machine do a fairly complex task under their control. Rather than teaching programming, they were aiming to teach the joy of programming. Then, with a bit of luck, folks who find this fun will move into more formal ways of making this happen and turn to real coding.

I downloaded the free Kodu Technical Preview which runs on the PC (you can also get the program on Xbox Live for 400 credits) and had a play. It is great fun. In no time at all I had created a world and had my little creature running round after the ball and picking it up.  I want to have another go with this.

I can see this being one of those things you show your kids and then after a while they will grab the gamepad and kick you off the machine so that they can have a go at finding all the things you can do with the environment. At first I was comparing the system with Little Big Planet, which also offers a way you can build your own worlds, but I think Kodu is better in this respect. It is presented from the start as an environment where you create behaviours, rather than as a platform game you can add things to.

From a teaching perspective it is great in that it gets you thinking about a program as a sequence of actions and decisions, and that is fine by me. 

Free XNA Screencasts

pebbles

I’ve been recording XNA screencasts for the last six months or so for Thirteen1 magazine. The aim is to give you a gentle introduction to programming, using XNA games as the basis of the teaching.

I’ve just reached the end of the first section. If you want to view the screencasts, and download the practical sessions that go with them, you can find them on VerySillyGames:

http://verysillygames.com/Screencasts

Marking Minesweeper

4173607315

Spent pretty much all of today playing MineSweeper. Around 23 times. All of the first year get 15 minutes each to show off their programs and so Mike, Simon and myself were looking at how well they had done implementing this classic game.

It never ceases to amaze me how different people find their own way to write a program to solve the same problem. Some worse than mine, some better than mine. And just about all of them working.

In fact, some of them should make an appearance on Xbox Live at some point. They really were that good.

Student Session Fun

Did my first TechEd 2009 session today. Students and XNA. What could go wrong? Well, fortunately, nothing much as it turned out – except for one of my demos getting a tiny bit stuck.  The audience was great, and I took a picture of them all:

4094369495

On the left….

4094369831

..in the middle..

4094370193

…and on the right

Thanks for being a great audience folks. I hope you enjoyed it.

After my bit we were joined by some other TechEd speakers and we had a really good question and answer session.

If you want to find the links to my stuff, you can find silly games content at www.verysillygames.com

You can find my Yellow Book on C#, and my Orange Book on Java to C# at www.csharpcourse.com

I will be posting the slides for the session, along with all the sample code, on this blog after my session on Wed.