Thought for the Dazed

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

Flickr
Twitter
C# Yellow Book

Search entire site
Thursday
May162013

Nokia Champ Rob

I found out last week that I've been appointed as a Nokia Developer Champion.

I'm not sure if it is for those WAP pages I used to write for my Nokia 7110 (I actually had a script that would read my email and convert it into WAP so that I could read my mail on the move), but it is rather nice.

Thanks to those of you at Nokia who thought enough of me to make the award. I hope I prove worthy of it.

Wednesday
May152013

Bill Bailey at Hull City Hall

DSC00463.jpg

Playing classical music on car horns. And why not?

I saw Bill Bailey a few years back when he came to Hull. And today we saw him again.  It is amazing to think that one person can entertain a building full of people by just standing there and being funny. But he can. If you get the chance to see him on this tour, just go. Great stuff.

Tuesday
May142013

Deal Extreme for Extreme Deals

If you are looking for anything electronic, and lots of things strange, then I can reccommend these folks. They have a huge range of stock which changes by the hour and includes lots of exotic and interesting components. They price things in dollars and their delivery is free (but very slow, allow four weeks). You can pay with PayPal, which is nice too.

I had a need for a little USB hub and network thingy and these folks were able serve up just what I wanted, at a very sharp price.

http://www.dealextreme.com/

 

Monday
May132013

What use is a structure?

DSCF1594.jpg

It is exam season here in Hull. Later in the week we have our programming exam. And I’m getting quite a few questions through about C# and stuff. Today I got asked the question “What use is a struct?”. I’ve been spending a lot of time talking about classes and references and how clever they are, and someone wants to know why, if classes are so wonderful, some objects in a program are managed by value. The answer is simple enough. It is because sometimes you really want a value which you can just copy around easily.

Consider the Rectangle type in XNA. We can use this to represent the position and size of something on the screen. And this is a struct, not a class. Take a look at this code:

a = b;
a.X = 99;

If a and b are both Rectangle variables the effect would be to set a to the value in b and then move the X position of a to 99. This would not affect the position of b.

If the Rectangle type was a class then we would have two references, a and b, that both refer to the same object in memory, so moving a would affect b as well. If we want to place objects in lots of different positions on the screen, and we don’t want them to be linked in any way, then structures managed by value is the way to do it.

Note that things like Textures are managed by reference. This makes a lot of sense too. An image is a large thing, and it is often very useful to be able to share one image for a whole bunch of things. Think multiple sprites in a space shooter. They will have a Rectangle value to give them a unique position and then a reference to a texture that they all share, to give them an appearance.

The XNA framework is full of objects that are actually structures because they work better this way. For example Color, Point and the Vector objects are all structs so that we can manage them by value. In fact, now that you know how it works, you should be able to look at any XNA type and figure out whether it is a class or a struct, just based on how it is used.

Sunday
May122013

Page Navigation in Windows Phone Applications

IMG_6478_79_80.jpg

I got asked a question about Page Navigation in Windows Phone applications. Having a spare 10 minutes I thought I’d record a tiny screencast about it, which you can find here.

It tells you how to make a multi-page Windows Phone application and then navigate between the pages. You can find the sample application here. The text that is referred to in the screencast is the Windows Phone Blue Book, which you can find here.