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

Entries in Serious Stuff (54)

Thursday
Aug292013

What does ?? mean in C#

WP_20130829_17_11_38_Pro__highres.jpg

I sent out a tweet asking folks if they knew what the ?? operator in C# does. Quite a few people did, which was nice. For those of you that haven’t heard of it, here is my explanation.

If you are a C# programmer you will know about references. The way that C# works, a variable can be managed by value or reference. A variable of value type is stored in a location in memory. For example:

int i;

This creates an integer variable called i. When the program runs the system will decide where in memory the variable should live. You can think of computer memory as a whole bunch of numbered locations. Because that is what it is. Perhaps the variable i could live at memory location 5,000. Then when we write the code:

i=99;

The effect of this is to put the value 99 in memory location number 5,000

So, if I write code like:

j = i;

This would copy the value held in memory location 5,000 into the location where the integer variable j is stored.

This is how value types work. Whenever we do an assignment of a variable managed by value what happens is that the value is copied from one memory location to another.

So, what about values managed by reference? Well, in these there is a level of indirection between the variable and the actual data. Suppose we have a class called Account, which is managed by reference.

Account a = new Account();

This statement makes a new account variable and then sets the variable a to refer to it. The variable a will hold a reference to the new Account. Perhaps the new Account will be located at memory location 10,000 which means that the variable a (which might be stored at location 6,000) will hold the number 10,000 – because that is where the Account instance is stored. The Account class might have a Name property, so I can write code like:

a.Name = "Rob";

When the program runs it will go to location 6,000 (where a is stored) and read the number out of there to find out where the Account is. In this case the variable a holds the number 10,000 and so the program will go to the Account there and set the name.

So if write code such as:

Account b = a;

This creates a new Account reference called b which refers to the same Account instance as a, in other words it will refer to location 10,000.

So, in the case of the value the information is just there in memory, but for a reference we have to go where the reference refers. With references you can also set them to null:

a = null;

This has the effect of putting a “magic value” in the variable a that indicates it really points nowhere.  It is a way of saying “this reference does not point to any object”.

The null reference is often used in programs to indicate that the thing you asked for could not be found, or hasn’t been made yet, or doesn’t matter.

This “nullability” is so useful that people wanted to be able to make values “null” as well. So they invented one.

int? ageValue;
The addition of the question mark makes an integer variable (ageValue) that can be made null. For example, the bank might store the age of a customer when it is important (when the age is less than 20 say) but once a person reaches a certain age, from then on the age is completely irrelevant to the system. They can mark the ageValue as null to indicate this.

ageValue = null;

Programs can also test for null

if (customerAge != null)
{
// Stuff you do if the age matters
}

In XNA you often find nullable value parameters being sent to method, so that the method can know to ignore them.

So, I’ve been writing for what seems like ages, and I’ve still not explained what ?? does.

Well, ?? provides a convenient way that I can map the null value of a nullable variable onto a specific value

int actualAge = customerAge ?? -1;

It saves us having to write code that tests for null and sets a value appropriately. The above statement sets the value of actualAge to the value in customerAge unless the value in customerAge is null, in which case it sets it to –1.

if (customerAge == null)
actualAge = -1;
else
actualAge = customerAge;

In other words ?? is a short form of the above test.

Wednesday
Aug142013

Kids Can’t Use Computers?

DSC02256_7_8.jpg

A while back I read this post titled “Kids Can’t Use Computers – And This Is Why It Should Worry You”. It depressed me. Not because I agree with all of the sentiments of the author, but more because I worry that people may take this kind of viewpoint seriously. The underlying tenet of the article (I’ll save you the bother of reading it) is that only a few people can actually use computers, especially kids. And this is apparently a bad thing.

The author brings out a collection of “horror stories” of people who “can’t use computers” for one reason or another, including not knowing that their laptop has a WiFi off switch. It says a lot for the nature of computer folk that a good portion of the debate following the post is an earnest discussion of whether or not laptops should have such a switch. I’ve actually been caught out by this myself, and therefore, by definition, am unable to use a computer. Oh well. Back to the drawing board for me.

The author completely misses the point that it is perfectly reasonable to expect that things should just work. Engineers have been very good at producing products that “just work”. I can remember when starting a car in cold weather was a tricky affair which was involved lots of fiddling with the choke and pumping the accelerator pedal. Nowadays you just push a button.

Cars have been around for well over a hundred years, and their fundamental function has not changed over that time. Computers have been around for much less than half of that and we are still discovering new things we can do with them. I think it is safe to say that we have a much better handle on how to make a useable car than we do a useable computer. Which means that people will sometimes have problems getting their systems to do what they want.

The current generation of computer hardware and software is very prone to failure when confronted with frailty of human nature in all its forms. But people will translate their experiences with their cars to computers. Why should the computer not just work when I press the button?

It is interesting to watch kids use technology, to see them running their fingers over the TV screen and expressing surprise when it doesn’t respond to their touch. To see them start watching a video on an iPad and then become confused when the video doesn’t just continue on the TV when they turn it on. They are going to see these things as omissions that need to be fixed, not evidence that they are too stupid to use those devices. And quite right too.

So what do we do about it? The author suggests a “back to basics” approach so that everyone can learn as much about the low level functions of computers as he is evidently proud of knowing. Then we can all argue about the best version of Linux to run on a mobile phone while our kids throw things together and build the future out of what sticks. Just like it ever was.

It is very important to learn the low level stuff, to have an understanding of the limitations of the computer, what they are really good for, and how you get them to work for you. Learn to program. Absolutely learn to program. But then use that ability to make things and have fun making things. Take ideas (silly and otherwise) and give them life. Spread them round. Build solutions and games that make people happy (or at least smile). Learn about the technology by playing with it. If it turns out that your ultimate interests lie outside the realm of processors and memory then that’s fine, but an understanding of what a computer is good for and how you make it work is always really useful to have.

Never regard your skill with computers as marking you out as in any way special unless you can do everything else as well. I can write code, but I can’t draw for toffee. If an artist comes to me with a computer problem I’ll not call them stupid if I can solve their problem and they can’t. Because I can’t do what they can. 

A proper computer professional is as good with people as he/she is with computers. In fact, bearing in mind that a lot of computing is finding out what people want and then making a happy ending from their wishes, I reckon that good inter-personal skills are more important in computing than they are in just about any other field. Work at these as you would a new programming language. And learn to write well.

For me computing is all about having fun making stuff and engineering happy endings. I’m not looking for a future where everyone is “clever” enough to use a computer. I’m looking for a future where we have enough people around who are able to produce compelling and useful applications for those who want to use computers to make their lives better. In other words, computers should “just work” and we should have folks around who are skilled enough to make this happen (and enjoy doing it).

Saturday
Jul272013

Writing with Colour at the Guardian Masterclass

DSCF3564.jpg

Anyone can write, just like anyone can cook. As soon as you move from restaurants and ready meals to getting ingredients and mixing them in pans you can start thinking about getting a white uniform and people shouting “Yes chef!” to you across steam filled kitchens. Moving beyond shopping lists and one line Facebook updates means that you can start pondering putting “writer” on your business card and extracting killer quotes from unresponsive interviewees. Or then again, perhaps not, because of course the really important thing is what everyone else calls you.

If you are the only person that thinks you are the next Jamie Oliver then you might have a hard time getting folks to eat your food.  And while the internet does provide a potential audience of billions, getting them all to come and read your web site will take more than just your idea of deathless prose. This means that you have to do the hard stuff, like practice and learning how to get better.

I’ve never dared call myself a writer; I’m more someone who throws a bunch of words at a blog post every day to see which ones stick. But today I went along to a Guardian Master class called “Writing with Colour” to find out a bit more about this writing business. There was actually another reason for going as well, the sessions were being given by writers who I’d long admired from afar, and I liked the idea of admiring them from a bit closer up.

There were about 80 or so of us on the course, which took place in the actual Guardian newspaper building in London. The sessions were all great. If you have a low opinion of journalists and editors then you should go along, just to find out how thoughtful and considered these folks are about what they do.  I’m pretty sure that not all writers are like this, but these were folks who I’d be happy to listen to all day, which is just as well, because that is what we did.

A few of my thoughts from the sessions:

Read what you have written. Out loud. All the writers took evident pleasure in reading what they had put on the page. This is as confidence thing I reckon and darned good advice. Sometimes you might like what you hear. If you don’t like it, go back and change it until you do.

Be loyal to your work. This can mean a bit of internal wrangling as you seek permission to print that quote from a reluctant interviewee. It might mean you can’t be a totally nice person all the time. And it might mean dropping that wonderful sequence because it doesn’t add anything to the piece.

Always deliver what you were asked for. Someone asked Lucy Mangan what she did if her four o’clock deadline came along and she hadn’t thought of anything to write about.  Her reply was brilliant. That. Does. Not. Happen.  If you are a proper writer and you are asked to write something that’s what you do. You can wrestle with your inner demons about the content (and you should) after you have pressed the send button, but the important thing is if you are asked for 550 words you should deliver 550, along with a convincing pitch for why you should be allowed another 200 or so.

Always edit, and always cut. The editor is the person who makes things better and tighter, sometimes by cutting out what the writer thought of as the best bits. If we end up losing the traditions of print journalism I reckon the editor is the person we will miss the most. This probably means that writers will have to spend more time editing their own work. So try to do this.

Work at what you write. I was very pleased to find that nobody said that they found writing easy. Everyone said they had to work at it. Interviews take preparation and persistence in writing everything down. Features take research and rewriting.  And the work doesn’t stop when the piece is finished, everyone valued re-visiting items and look at why they wrote what they wrote.

Seek out the colour. Work to find that killer fact, or interesting angle, which will give you a hook to hang your words on or will be quoted in the pub by your readers. If you are very lucky the colour will find you, but mostly you find it in the research you did, or the huge pile of notes that you made.

Last week I sent a jaunty tweet to the organisers saying how I was bringing along some crayons, as the subject was “Writing with colour”. I can imagine the sinking feeling in the stomach of the recipient, along the lines of “We’ve got a right one here….” Sorry about that.

Anyhoo, I found the whole affair really stimulating, and if you want to get tips about improving your writing style, and maybe meet a few heroes, then it is well worth the price of admission. And the lunch was good too.

DSCF3560_1_2.jpg
Wednesday
Jul172013

Think of the Audience

DSCF0504_5_6.jpg

Some time back I wrote a blog post about the most important thing in a project. To save you the trouble of reading it again, I concluded that the biggest risk that any project can run is that you might not  be able to make it work.

I’ve been thinking about presentations in a similar light having seen a bunch over the last week at the Imagine Cup. So, what’s the most important thing in a presentation. Is it the script? The demos? Running to time? The jokes?

Actually I reckon it’s none of these things. The most important thing in any presentation is the audience. If you don’t build your presentation with them in mind then it will not go as well as it should.

Thinking about the audience begins at the start, when you worry about whether or not what you are going to say will make sense, has the appropriate level and the like. I reckon that the thing an audience likes the best is a story, so presentations that have some kind of narrative flow are going to go well.

During the presentation you should be watching the audience to make sure that what you say is going down well, and don’t be too afraid to change tack. Asking questions to confirm that you are going in the right direction is a good idea too. It builds your confidence and establishes a rapport.

If you are now thinking “Great, now I have to worry about watching the audience as well as everything else…” then I’m sorry about that, but I think it s something to keep in mind. For me the worst presentations are where the presenter just talks at the audience. You should try and make the presentation a conversation as much as you can. With very large numbers this can seem a bit daunting, but remember that an audience of 10,000 people is actually made up of 10,000 individual people.. If you think in terms of talking to just one of them, then that will help you manage this.

For me the best presentations I saw last week were those that engaged the audience from the start. So see if you can do the same when you stand up and start talking.

Tuesday
Jun182013

Heading for London

DSC_0196.jpg

Ian Livingstone playing the game that got us to London. He reckons we should set it in space, and I think he might just be onto something….

To start with, a bit of history. What seems like ages ago David, Simon, Lewis, David and me took part in Global Game Jam Hull. And we built a game. Then Microsoft offered a prize for the best Windows 8 game that came out of the Game Jam and made it into Windows Marketplace. So David and Simon took the game engine, made it marketplace ready and shipped it. And Heartotron won. At the time we weren’t sure just what we had won, but part of the prize turned out to be a trip to London to tour a game development studio and meet up with some of folks who made the game industry what it is. And so we found ourselves on a train at 8:00 am in the morning, speeding through the sunshine and looking forward to an interesting day.

Which we got in spades. It was great. First up was a look around Lift London, a shiny new Microsoft game studio with a focus on making games the Indy way. No big (or at least huge) teams, flexibility, appropriate technology and total commitment to the product are the order of the day. Lift London also sees incubating fledgling games developers such as Dlala as part of their remit, which is very interesting.

With people on the team who can say things like “..and then we went on to write Banjo-Kazooie…” or “..and then we did Singstar..” alongside folks who have grown up writing and pitching games any way they can I reckon we can look forward to some fun stuff in the future.

We got to look at some work in progress, which was fascinating for me. The transition from ideas to drawings to models on the screen was intriguing.. I get very jealous of people who can draw, and loved seeing these people in action, and how they can turn out lovely looking artwork with just a flourish of their Wacom pens. Most impressive.

Then it was time to move on to Modern Jago, a pop up venue in Shoreditch, for workshop with the gaming legends Ian Livingstone (Vice chairman of Ukie, Games Workshop founder, president at Eidos), Andy Payne (chairman of UKIE and CEO of Mastertronic) and Philip Oliver (TIGA board member and CEO of Blitz Games Studios).

Each had plenty of time to speak and plenty to say. Some things that I took away, in bullet form:

  • There has never been a better time to be writing games. Cheap tools and an easy path to market give you amazing potential.
  • There has never been a more competitive time to be writing games. The statement above is true for everybody.
  • Put your monetisation in at the start. If you are going to sell your game, be up front about that (although recognise that very few people will part with cash to buy it). If you have a pay to play model, put that in the central game mechanic. It is impossible to add it later.
  • Use metrics and feedback. Track downloads, watch for reviews and scores, use telemetry to be able to tell how far people get through the game, how long they play for, and when they give up. Phase your releases so that you get feedback from one part of the world (for some reason Canada and New Zealand are popular for this) before you go global.
  • Look for the “soft” market. A big splash in a small pond with a future has more potential than trying to make an impression in a huge marketplace with scant resources.
  • Get a following. Napoleon reckoned that with 1,000 followers you have an army of your own. He wasn’t on Twitter, but you can be. Give opinions and help to people out there and build a following of folks who like you. A crowd who like what you do and want to see what you do next are great to have around. Be loyal to them and they will replay you by supporting what you do.
  • Get a job. You might plan to be a lone gunfighter releasing your fantastic stuff for the world to marvel at, but it much easier to do this with a roof over your head and a full stomach. One of the things you need to succeed is luck (everyone said this). Napoleon (him again) reckoned that he always preferred his lucky generals to his clever ones. If the luck isn’t there, and it may not be, you still need to eat. Make time for your development and go at it full tilt, but there’s nothing wrong with having a backup plan.
  • Get some “skin in the game”. This kind of goes against the above but I still feel it is something to think about. If you feel that the stars are aligning and that this is “the one” then feel free to go for it every way you can. Living in a van for six months while you raise funds and build your product base might be the thing you have to do to achieve success. Worst case maybe your boss (see above) will have you back – particularly if you part on good terms.
  • The three most important aspects of a game are playability, playability and playability. But graphics and high production values are a way to distinguish your product and get people in to discover just how good your game is. But this, of course, costs money and time. As does buying a place in the charts that gets you noticed, something else which might be a necessity.
  • Put yourself out there. I was particularly pleased to hear this one, as it chimes with what I’ve thought for years. You need to be able to do the “front of house” stuff. This is really bad news for software developers, who tend not to be the most extrovert folks, but it is a necessary skill. Get yourself in front of people. Practise doing stand-up, meeting and greeting and networking. If you don’t have these skills other people will not compensate for your lack of them. They’ll just find someone else more interesting to talk to. Ian Livingstone himself said that this is one lesson he took a long time to learn. The great thing about computer folks is that they are used to picking up new tools and APIs. Treat this as just another thing you have to learn and get good at.
  • Make a good story. The press is interested in you, but only if you are interesting to them. “I’ve made a fishing game” is not useful to them. But “I’ve made a fishing game that I wrote underwater whilst wrestling a Great White Shark on the Barrier Reef” is. Make sure that you have a good tale to tell. Use your followers (see above) to big you up and help you get noticed.
  • If you are working as a team, set some ground rules (another favourite of mine). Have a plan for what to do if your lead developer gets a “proper” job and stops writing your game engine. Have a protocol and a policy for re-negotiating your arrangements when these events happen.
  • You don’t need to be the best, or cleverest. Just there are the right time, in the right place, with the right thing. Try lots of things, in lots of places as frequently as you can. Don’t expect success to happen the first, second or perhaps even the third time. But as soon as you get a sniff of something that seems to be working, follow it, develop it and ride it, and you might be the next big thing.

All in all a fantastic day out. Thanks to Microsoft for setting it up.