Hard Code on the Web

I've mentioned I.M. Wrights "Hard Code" book before on this blog. It is actually written by a bloke called Eric Brechner, who adopts the I.M. Wright persona to write hard hitting, controversial, articles about software development best practice. When I mentioned the book before I said that I thought was worth a look. Having finished reading it I've changed my mind.

You must read this book. It is excellent. The even better news is that I.M. Wright also has a blog that is an equally good read. You can find it here.

Head in the Clouds

Sorry for the title. I find cloud computing quite easy to poke fun at. In fact:

"Are clouds the ultimate form of vapourware? And if is called Windows Azure, surely that's the colour of the sky, not the clouds? Shouldn't it be called something like 'Windows White and Fluffy'".

See. Easy. Although after the sessions today I think it is probably a bit unfair.

I was up very early, almost in time to catch the third bus to the conference centre.

2981235018

This scene was outside the hotel at 7:00 am this morning. I think it sums up the American Dream quite nicely.

But enough of this, the keynote started at 8:30 and so after a very nice breakfast it was down to the really big hall.

2980380295

This is just part of the Hall.

Ray Ozzie took over from Bill Gates earlier this year, and this was the first time that he had flown solo so to speak.  He was very good, describing his vision of computing that is just "out there" very well. I'm less convinced by the sample application that they chose to first articulate this vision though, the BlueHoo social networking app that lets you find out if anyone around you is someone you know - I kind of high tech, Bluetooth powered, cloud network,  version of looking and shouting.

But that aside, the underlying thinking seems very solid, and when I heard that one of the people behind the cloud architecture was Dave Cutler, the man who made Windows NT all those years ago, I was much more interested. Windows NT is the basis of the technology that sits underneath all the Windows desktop and server platforms.

2981236454

Ray on the stage

Whether or not cloud computing is the next big thing is debatable, but you can't deny that it is big. What Microsoft want to do is provide a means by which you can take code that you have written using conventional languages and tools and put it up on their servers so that anyone can use it, from anywhere in the world. And if millions decide to use your program, they can - because the underlying system will handle the distribution of the software around the world and the balancing of the load on the various servers.

Of course horsepower on its own is no good to you, there is also a need for data stores of various kinds. from blobs of data to SQL databases. And all this must work in an environment where systems crash, networks fail, and bad people are out there trying to break things all the time.  Tricky stuff.

If Microsoft can pull this one off they will really have moved computing onto the next stage in its development. The architecture and the way you manage your programs seems very well thought out, although they admit that the system will be a "work in progress" for a while yet.

As far as I'm concerned it is all very exciting. People write software so that others can use it. The cloud means that if I have an idea for a million user, killer application - say I want to write the next MySpace - then I don't have to worry about getting server farms, buying network bandwidth and hosting all the user's data. I can get just put my application out there on the cloud behind a network address for people to use.

Of course money will have to change hands. Microsoft will want me to pay them to host my software, but this payment will be based on the use of my program. I only have to pay for the services that I consume. I'll pay more if I have more users, but since the more users I have the more income I should have then it all comes out OK in the end. This is a new business model that anyone who writes programs that provide services to others will have to take note of.

The thing that really does it for me though is the way that I can now take C Sharp and Visual Studio and write code for thumbnail sized computers to control my Christmas tree lights or go all the way to the other end of the spectrum and turn out an application for millions of people to use. All with the same essential skills. 

I went to a few more talks on Windows Azure as it is now called, and I must admit it looks good.

And I'm feeling a bit guilty about poking fun at it.

Doors and User Interfaces

As part of the refit of our department we have got all new doors. These are rather swish, and the ones to our offices have windows in them, to let light into the corridor and give everyone a view of what we are doing. I'm going to stick a picture of someone working on the inside of my door window.

Anyhoo, the main doors have been replaced too. And they've solved a problem that has bugged me for literally years. They only have handles on one side.

Version 1.0 of the doors in our building had handles on both sides. This lead to significant levels of confusion and wrenched shoulders, as people like me grabbed a handle and heaved manfully to find that the door doesn't open that way. I got quite good at looking for door hinges, and even invented a rhyme to help me remember what to do: "If hinges you see, then you should pull me". Unfortunately not everyone did this, and so version 2.0 of the doors added little labels with explicit "Pull" or "Push" instructions.

Version 3.0 of the doors, where we are now, have the innovation that if you are supposed to push the door there is no handle to pull. This is a great idea, in that if you can't do something there should not be a way of trying to do it.

From a user interface point of view there is a school of thought that says if you can't do something, the option to do it should not be present. This means that unusable program functions should be either grayed out or missing. This lines up nicely with doors version 3.0.

I used to think that this was always a good idea, as it means that users don't get frustrated when they try to do something and the system tells them they can't do it. However, it can lead to even more frustration, where the option or command is tantalisingly visible but can't be used, or worse yet, other people claim that they have the command and you don't. In the case of doors it is easy to see what to do from the start, you either pull or push, but with software things are always more complicated.

In my programs I now tend to enable all the features and then have a helpful message that appears and tells the user what they need to do to make it work. Rather than saying "Not Allowed" the message would be "You must log in to perform this command" and give a link to the appropriate help.

Loading Web Pages

I don't usually put up techie pages with code in them, but today I present something that I think might be useful and I've not found anywhere else. It is part of my RSS reader for the XNA display program, and it solves a couple of problems that you might hit. My feed reader needs to read feeds that are on a password protected site, and it also needs to read feeds that are compressed. This method does both:

private StringBuilder readWebPage(
    string url,
    string username,
    string password,
    string domain)
{
    // used to build entire input
    StringBuilder sb = new StringBuilder();

    // used on each read operation
    byte[] buf = new byte[8192];

    try
    {
        // prepare the web page we will be asking for
        HttpWebRequest request = 
            (HttpWebRequest)WebRequest.Create(url);

        if (username.Length > 0)
        {
            request.Proxy = null;
            NetworkCredential credential = 
               new NetworkCredential(username,
                                     password,
                                     domain);
            request.Credentials = credential;
        }

        // execute the request
        HttpWebResponse response =
            (HttpWebResponse)request.GetResponse();

        // we will read data via the response stream
        Stream resStream;
        Stream inputStream =
            response.GetResponseStream();

        // Might have a compressed stream coming back

        switch (response.ContentEncoding)
        {
            case "gzip":
                resStream =
                   new GZipStream(inputStream, 
                          CompressionMode.Decompress);
                break;
            case "":
                resStream = inputStream;
                break;
            default :
                debugOutput.PutMessageLine(
                    "Invalid content encoding: " +
                    response.ContentEncoding + " in: "
                    + url);
                return null;
        }

        string tempString = null;
        int count = 0;

        do
        {
            // fill the buffer with data
            count = resStream.Read(buf, 0, buf.Length);

            // make sure we read some data
            if (count != 0)
            {
              // translate from bytes to ASCII text
              tempString = 
                Encoding.ASCII.GetString(buf,0,count);

              // continue building the string
              sb.Append(tempString);
            }
        }
        while (count > 0); // any more data to read?

        return sb;
    }
    catch (System.Net.WebException w)
    {
        debugOutput.PutMessageLine(w.Message);
        return null;
    }
    catch (System.Net.ProtocolViolationException p)
    {
        debugOutput.PutMessageLine(p.Message);
        return null;
    }
    catch (Exception e)
    {
        debugOutput.PutMessageLine(e.Message);
        return null;
    }
}

This is not very elegant code, but it does work. I've pulled it straight out of the program and so there are a few things you need to know. I have a class called debugOutput which I use to send messages to the user. You either need to create one of your own, or remove those lines. If you need to use a username and password you need to add those to the call, otherwise you can leave those fields as empty strings.

Students at TechEd 2008

One of our students came to see me this morning. He is hoping to go to TechEd 2008 in Orlando and wanted me to write a supporting letter for his visa application.

You bet I will. I'm actually going to TechEd 2008 myself (I'm giving a session on the .NET Micro Framework) and I know what a great experience it is. Particularly if you are a student.

I've advised him to prepare carefully before he goes to make sure that he gets as much as possible out of the trip. He should be able to get his session schedule sorted out in advance of the conference, and he really should make use of the Hands On Labs to play with the latest toys. There are also discount Microsoft Certified Professional tests that can be taken on site, but for me the most wonderful feature of the event is the "Ask the Experts" bit.

It continues to amaze me that Microsoft puts its absolute top dogs out there for the public to harangue.  Perhaps it is because they are too cheap to hire "booth babes", but I like to think that it is because the really want their developers to meet up with the people that use their stuff.

When you go and talk to someone on the XNA, or Micro Framework or Sharepoint or whatever stand at "Ask the Experts" you are actually talking to the product managers and developers that make the product. They aren't just customer support people, they are the authors themselves. Most delegates at the conference just use this opportunity to see what swag is being given away at each booth. But a few have cottoned on to this part of the conference and take the opportunity to get deep answers to hard problems.

I've told our student to make sure that he goes around the experts and has a chat with them, from my experience they love talking about the stuff they make and why they think it is the best in the business. I really hope he makes it out there, I just wish more students could get to go.

Very Silly Simon

I've had a rush of creativity. No, really.

2433042673

This is a screenshot of the Simple Simon Project at Very Silly Games. It will eventually be a pattern matching game remarkably like another game named after a pieman.

I've only written the first bit for now, with some questions that you can use to brush up your programming smarts. Study the code and answer them and we will see about moving onto the next phase of the development.

The Return of Jetlagged Software

I woke up at midnight here, 8:00am back home. Of course it is time to write some software. I started doing this in Seoul last year, and now I'm doing it again. We went out shopping yesterday and I frequently wanted to know how much things were in pounds. Of course you can get a very rough idea by dividing dollar prices by two, but I wanted more accuracy. You also need to factor in the local sales tax, which comes in at 9%. What I wanted was some form of Damage Calculator which would hopefully discourage me from spending too much. As if.

I wrote a currency converter jetlagged app last time, and so I thought it would just take the code and modify it. Except that the code is of course on the computer I took to Korea, not this one (I really must work on my source code management).

So I've written a better one. It converts from dollars to pounds and back, working out how much you lose to tax each way.

2410041822

What you get if you enter the price of, say, a PS3 Dualshock 3 controller that you are probably going to buy. That will do nicely.....

If you are lucky enough to be in Seattle and need this, you can find the code here. Just unzip the binary and drop it into your mobile device.

Why Software Sucks...

There are some books that anyone working with computers should just read. Code Complete by Steve McConnell is one of them. And now I've found another one.

Why Software Sucks... (and what you can do about it)  is by David Platt is a book you really should get. It is not hugely technical. It is not hard to read. It will make you laugh (and if you are a developer promptly feel guilty). It is a text which takes as its starting point the fact that we are not really very good at writing software.

It ties in rather neatly with a lot of things that I tell our students when they are writing programs for other people to use, but it also touches on security and a whole host of other issues, always with humour and always grounded in real life experience.

Even (or especially) if you are not a programmer you must read this book. Excellent stuff.

Unconscious Activity

Figure 10
Learn how to do this....

I've just been sent a question about an article that I seem to have published. I sent it over to the OpenNET people and they put it out in August this year. It is all about Image Processing in C# on a mobile device. If you want to take a look, get the code and get the articles, take a look here:

http://community.opennetcf.com/articles/cf/archive/2007/08/30/image-manipulation-in-windows-mobile-5.aspx

Slide 7 Conference Registration Open

Two years ago I helped set up a student conference down at Microsoft Reading. Everyone turned up, had a great time, learned stuff, drank some beer and went home. It was called Slide 5.

It was good.

Microsoft are doing it all again. Compelling (and very useful) content. Microsoft experts to talk to. A sesson from me. Free food (a BBQ even). And beer. Slide 7 is on the 18th of June and registration is free. You can find out more, and sign up, here.

If you are lucky enough to be a student at Hull who is still in Hull on the 17th - 18th I'm taking a mini-bus down to the event. We are going to stay in a Travelodge on the Sunday night and then go to the conference on Monday. You can sign up for a place on the magic bus here.

A Gaming Education

This is a text heavy post. Sorry about that, but I figured I'd better write some proper stuff so that the boss doesn't think I've spent all my time in SF (you are allowed to call it that once you've been here three days) wandering round taking photographs...

Today we discussed computer games in the context of education. Which has been very interesting. Quite a bit of the discussion has been outside the scope of what we presently do at Hull, but it is fascinating in itself. At Hull we teach Computer Science with Games Programming.

The word with in our course title is very important. It means that we are going to make you into a Computer Scientist, but one who can work with the particular needs of the computer games industry. This means that you'll be grappling with performance issues, 3D graphics, physics and artificial intelligence, because that is what sits underneath games and makes then tick. You will also be dealing with things like project management, software engineering and working in a team, because this is how games are actually got out of the door and into the shops.

We do not teach game design, story telling, character construction or fine art. These are totally separate fields and dealt with by specialist team members. However, a lot of folks at the conference do teach this material. And it is fascinating. We had some game industry gurus along to give us their take on education and research and the results are thought provoking stuff.

The first thing that came up was  how little we really know about computer games and education. We are only just starting to figure out what categories of material there are in the field, and how they relate to each other, and what we can teach about them. There is quite a bit of resistance to teaching about games in academic circles, which I think is a shame. Media is a well established area of study, and I think that compared to computer games it is somewhat shallow.

After all, we don't find completely new forms of TV receiver, with new and interesting abilities, appearing every five years. And the narrative and structure of content delivered with just a picture and some sound that you sit in front of is much more restrictive than something that you can interact with directly. Perhaps things will change, perhaps we'll get the word game out of computer gaming, align it with the entertainment field, and then it will become more respected as an area for study. Perhaps.

Doug Church from Electronics Arts delivered the keynote, talking about research in computer games. The news was not good. Points that he made included (apologies for any mis-quotes):

  • From a research point of view the games writers don't know  what they want, over and above the immediate problems that they have to solve in the present release. Blue sky research would be nice, but who has time for blue sky?
  • There is no grammar for describing content. Games are described in terms like "a bit of Grand Theft Auto with a Tekken twist" because there is simply no other way of expressing what they are.
  • There is no publishing culture in the games business. After all, why would you give away your hard earned knowledge in a paper for others to read? The way that ideas and techniques move around is when people move with them.
  • There are no shared tools between academia and industry. Industry builds up and  tears down tools so rapidly that these are usually unstable, transient and poorly documented, and so of limited use anyway.
  • Games writers hardly ever use books about game design, or techniques which are taught for this purpose. They go with experience and track record when deciding what to do and who to hire. They also play lots (and lots) of games - which academics may not.
  • Not all game writers read published research, although they can be enticed into it by a good looking demo.

So, with all that said, what do we do? Well, there was an acknowledgement that students are where the future is at, and they must be connected to  the profession, preferably on a one to one basis. Computer game education should be seen as "an invitation into a community and a chance to choose a future". In other words, a game you might like to play I suppose.

The way forward is through frequent, immersive, collaboration between student, teacher and professional. The way I see it, this could just about work. As long as students understand that the business is a profession, and not just a way to live out your fantasies, the industry starts to take a longer term view of research and academics start to play more games and take them more seriously.

Then Doug said something which really cheered me up He emphasized how important it is for the game creators to function as a team, communicate ideas to each other and plain just work together. "Human interaction is the hardest part of the job".We've been hammering this at Hull for years, and it is nice to see it brought out again as a priority by the game makers. He also mentioned that estimation is important. Whenever you do something you should try and work out how long you think it will take. Apparently he process of making  a wrong guess is very useful educationally...

Then after lunch we did some work on creating gameplay that was intriguing. We played a game involving bits of paper and paperclips, and then fiddled with the rules and changed the scenario. This was great fun. At the end we had something that we might want to take somewhere into a computer program. Things that came out:

  • If you want to teach with games, you are going to teach procedures, not facts.
  • The items in the game end up being incidental, whether they are monsters, buildings, cars, people or whatever. Players figure out what they represent in terms of the game and then work with that.
  • You can completely change the character of a game by making very simple, subtle changes to the rules of play.
  • You can design really interesting gameplay just with paper and paperclips.

I'd love to take these ideas and get students to brainstorm some gameplay and then build it. I'm not sure if this would be part of our taught provision at Hull, but it would be good fun for our fledgling game creators club to have a go it. Inspiring stuff.

Maxing out Vista

I managed something today which I didn't think was possible. I managed to get my machine to use up nearly all its memory. I was testing a SideShow gadget application which starts running automatically when the SideShow device is connected. But because I haven't completed the code yet, the program didn't finish properly. So Vista started it again. And again. So I ended up with several hundred copies of the program in memory before I realised what was happening.

403841557
86% and counting...

By the time I worked out what was happening I had 86% of my memory filled up. The nice thing is that Vista never really slowed down or seemed to suffer. I just saved my files, shut the machine down and rebooted. Which is quite impressive when you think about it.

Cheesy Wotsit Challenge

I've been giving the first XNA lectures to students this week. This is actually a world first; the first time ever that XNA has been used to teach C# to first year students in Hull by a tall bloke who needs a haircut.

Anyhoo, it has gone pretty well. I had a few minutes spare at the end of the lecture so I showed the students "Hot Salad Death With Cheese". I've given them the source of the code and offered a bag of Walkers crisps as a prize for the person who produces the best game based on it. If you fancy a go you can pull the files down from here.