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.

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.

Pulp Dates for your Diaries

Summer Bash Three Thing Game May

I’ve been playing around with the Pulp-O-Mizer to make some posters for the social events coming down the tracks at the end of this month. You use the web based interface to design great “future-retro” magazine covers.

If I lived in the ‘states I’d be able to get posters and other stuff sent through with this lovely artwork on it. There are also interactive comics and all kinds of good stuff. Well worth a visit. 

Matt Smith at the Imagine Cup Finals

Imagine Dr Who

Good grief. I mean golly gosh. I mean wow.

I’ve been involved with the Imagine Cup for a while. I sit at my computer writing emails and looking at entries and usually see it as “a student competition that I play a small part in helping to make work”. Then, when I go to the World Finals and I see just how much effort Microsoft put into it, and how much it means to the students that take part, I get the big picture.

I got another dose of “big picture” today when I found out that Matt Smith, currently doing a magnificent job as Dr. Who over on the BBC, will be hosting the World Finals in July. Blimey.

I’ve been a fan of Dr. Who since I watched it in the sixties on a black and white telly that could only receive one channel. To have someone like him taking to the stage on behalf of the competition marks a new high in my book. Amazing.

It looks like they are going to stream the finals live over the interwebs. It should be an awesome night.

The Proper Use of Exams

IMG_6422_3_4.jpg

I did a revision lecture today for the First Year. The exam is next week. Afterwards I got an email that I found both amusing and a bit irritating. The sender wanted to know what would be coming up in the exam this year “so that I won’t have to waste my time revising the other stuff”.

Oh well.

I think that person could use a slightly better perspective on why we are all here. I’m not teaching this stuff so you can get through the exams. I’m actually doing it because I want to pass on things which I think you should know if you want to do Computer Science. Another thing I find amusing/irritating (but also rather pleasing) is when we have students come back to Hull after they have graduated and say things like “You know, that stuff you taught is actually quite useful.”

Well, duh.

I use exams as a rather blunt instrument to make sure that folks learn the stuff that is really important about the subject. There is no secret about some of the topics that will be on the paper, since those things are there every year, and all you have to do is learn them. And by learning them I mean not being able to repeat the words, but actually achieve something using what you know. In fact, the way I see it, learning by applying the knowledge is actually much easier than just trying to bash in sequences of words that you can then trot out if you recognise the context of the question.

You could learn that “An interface is a set of methods that a class must implement in order that it is possible to create an instance of that class”. Or you could learn that you use an interface when you want to treat invoices, receipts, customers and any other objects in your solution as things that can be printed. The printing process only want to manipulate objects in terms of their ability to be printed, so you use an interface to describe the methods that give this ability and then make each object implement it.

Injustice: Gods Among Us

DSCF1655.jpg

Thanks, but I’ve been around long enough to know those…..

Number one daughter recommended “Injustice: Gods Among Us” as a good game. She reckons it is a good way to find out who would win in a fight between Superman and Batman. Since you can actually do that.

Yesterday I got hold of a copy. And she is right. Great game. I was expecting a good beat’em’up, but actually it is much better than that. There is also an engaging story mode that tells of Superman gone bad and even though it uses a Parallel Universe as a narrative device (quite the story telling mot du jour at the moment – hello Star Trek and Dr. Who), this does mean that you can have more interesting fights.

I got the game for the Wii U, figuring that the platform could do with some love at the moment. It works very well, with the Wii U controller either duplicating the video screen or showing you the player moves. I really like using the Wii U to play games. It now feels very natural to have a screen in your hands as well as in front of you. In fact, with Wii U consoles now available for around 150 quid I reckon they are a bit of bargain at the moment. Hopefully Sony will do something with the PS Vita and Microsoft with Glass to make the experience available on their platforms.

Anyhoo, we spent a happy afternoon working through various superhero permutations. Recommended.

Hull Collectors Fair

Last autumn they had a Movie Buffs fair in Hull and I went along and bought a few bits and bobs.Today there was another one and so we went along and took some pictures.

DSCF1652.jpg

Predator Jazz Hands

DSCF1638_39_40.jpg

Now, that’s a toy collection

DSCF1644_5_6.jpg

“Good time we had, yes”.

IMG_6960.jpg

What I bought, currently above the fireplace. Number one wife says it is “growing on her”, which is good enough for me. Anyone know the identity of the green guy with the red eyes and the figure to his left?

Pebble Watch

DSCF1624.jpg

So I  was looking something up on the http://www.coolcomponents.co.uk/ site. And I noticed that they had some Pebble watches for sale. They must have backed the Kickstarter at an early stage. Anyhoo, I’ve always liked different watches, and so I placed an order. And today it arrived. And very nice it is too. Very light, but not at all flimsy. And supposed to be very waterproof. You can see what’s inside here.

The watch uses a digital paper screen, rather like the ones in e-Readers. This allows it to display high contrast, high resolution (for a watch) black and white images very well indeed. It comes with a bunch of different watch faces which you can choose from. I like the big text one above. There is also a watch face SDK which you can use to make your own faces using a C program.

DSCF1621.jpg

Obligatory unboxing picture.

I’ve got the watch paired with my Nexus 7. It uses the Bluetooth connection to display emails and appointments and it works a treat. I’ve not got a great feel for battery life yet, but it went through the day without breaking a sweat.

What I really, really, really want to do is make it work with my Windows Phone. I’ve a horrible feeling that this will be rather tricky, even if I pair it with the phone and send data I’ll need to know what the protocol is. This is one of the very rare occasions where I wish I had an Apple or an Android phone, as it works with both of them. Maybe in the future it will be made to work with my lovely Lumia, For now I’m happy with what I get via the Nexus, but a phone connection would be awesome.

They say that Apple and maybe even Microsoft are working on watches like this at the moment. I can see why. I had a Spot watch a while back and I loved it (although you couldn’t really use it in the UK). A well connected, micro framework powered, version of the Pebble would be awesome. As it is, if you fancy something geeky but probably even useful, you should take a look.

Read the Specification. Please.

IMG_6292_3_4.jpg

I think that more software projects fail because of misunderstandings about the specification than for any other reason. The developer makes loads of assumptions about what the program needs to do and the customer can’t be bothered to keep an eye on what is being produced.

I was reminded of this when I was marking the first year coursework today. We set a tightly specified set of deliverables and then each student has 15 minutes to show what they have made. This is a lot of work. It takes five of us two and a half days to work through everyone. And then I have to spend at least two days going through the marked sheets and making sure that all the marks line up.

This year we set some quite complex deliverables and it was very pleasing to see that many students had risen to the challenge and produced some lovely stuff. But some of them had made really nice solutions to the wrong problem, because they had not read the specification in detail. They’d just read enough to convince themselves that they knew what was needed and then gone off and built it. And in many cases they needed to do more work to make their version than they would have needed to make the one that was required. Oh well.

Of course in a teaching situation this is not a huge problem. Folks lost a few marks and we moved on. And hopefully a lesson was learned, which is what it is all about.

One year I’m going to produce a huge, complex piece of coursework with a long and highly detailed description which has, right at the end, the phrase “Please ignore all the above. Just make me a program that prints “Hello World” in large friendly letters.”…

Lensbaby Bendy Lens

The LensBaby composer is a lens mounted on a ball and socket arrangement which you can twist to change the way that it focuses the light onto the camera sensor.

image

I bought one a while back and every now and then I get it out and have a play. It is quite fun. Very old school, in that it is basically a single lens in a sliding tube. There is no auto focus and you adjust the aperture (the size of the hole the light comes through) by dropping in and out little metal masks that are held in place with magnets. A bit fiddly to use, but the lens itself is pretty darned sharp, and you can get results that would be very difficult to get any other way.

IMG_6570_1_2.jpg

IMG_6547.jpg

IMG_6540.jpg

If you have a digital SLR and you fancy spending some time doing things the hard way, and never being quite sure how the pictures will come out, they are kind of fun.

Taking your Lumia 920 to bits

image

When I was a kid, whenever someone gave me some toy or other one of the first things I would to was take it to pieces to find out how it worked. To my credit, I was usually able to put the thing back together again, although I must admit that as devices have got more complicated I don’t do as much dismantling as I used to.

And the good news is that with the rise of the internets, I don’t have to. The folks at iFixit have recorded a lovely video of a Lumia 920 being taken to bits and then, most importantly, put back together again.

I’m not advising that you should do this kind of thing for fun, but the important part for me is that that I reckon that I could probably get away with having a go. Particularly as all the breakable bits like the headphone and usb sockets are on modules that look like they can be easily removed and replaced.

Even if you have no intention of ever taking your phone to pieces I recommend watching some of the video just to bring home just how much is going on inside that smooth plastic block.

Rob at TechEd North America 2013

TechEd

I’m very pleased to be able to report that I’ve been invited to deliver a couple of sessions at TechEd North America 2013 in New Orleans. I’m doing WPH-B302 “Secrets of using background agents for Windows Phone 8” and WPH-B301 “Speechifying your Windows Phone 8 Applications”. New Orleans is a place that I’ve always wanted to visit, and now I’ve actually got the chance to go there, which is great. If you are going along to the conference (and it looks like it is going to be very interesting) then it would be lovely to see you there. I’ve even got some new jokes just for the occasion.

Grand Finale Three Thing Game and Bash

IMG_6556.jpg

A couple of dates for your diaries. May 30th and May 31st. These are when we are doing our Grand Finale events for the year. On May 30th we will be starting a Three Thing Game and having a Summer Bash. Hull students can take part in either, or both. Tickets for the Bash, with the usual menu of video games, wordsearch, pop and pizza, will go on sale soon. And we will also be registering teams for the Three Thing Game. The timetable is tight, we are only able to run the events after all the exams have finished, and we want to make sure that if you are heading home at the weekend you can still take part.

We will be holding the thing auction at lunchtime on Thursday 30th of May. Teams will build their games on Thursday and Friday with the judging and awards on Friday afternoon. There will be a break for bash activities on Thursday evening. We’ve got Boss Alien, a game company based in Brighton, coming up to take part and help with the judging, and there will be the usual selection of awesome prizes and Lego.

I’ll be kicking things off on Thursday, but then I have to head out to New Orleans and TechEd US on Friday. I’ll be leaving everything in the capable hands of Simon, Martin, David and the rest of the team. In fact, there might even be a staff team in this TTG. I’m only sorry that I can’t take part in it.

Start your Own Business. Why not?

DSCF1601_2_3.jpg

Liz Johnson from the university Knowledge Exchange gave a Rather Useful Seminar on starting your own business today. We had a very good audience which was nice to see. The great thing about a Computer Science student is that they already have a bunch of skills that can actually drive a small business along.

There were some great tips for getting started.

Let people know that you are running a business

People like HMRC (Her Majesty's Revenue and Customs) like to be told if you are earning money. If they find out from someone else that you are working – which is pretty much guaranteed as soon as you get paid something by another company – then they might get upset and give you a hard time. Your landlord might need to be told if you are working from home, particularly if you customers back to your place for meetings. This will also affect your household insurance. If you are driving to customer meetings and delivering stuff make sure that your car insurance covers this. If you are starting a business alongside an existing job, it makes sense to tell your employer. They could get rather cross if they find out, and you might be able to work with them to leverage some useful synergy (proper business talk eh?)

Cover yourself in respect of liability

Perhaps the most important one here. Make sure that you have insurance that will cover you in the event of a dispute with a customer. Nobody starts a job thinking that it could all go wrong and you could get sued, but it can happen and you need to have protection. This is kind of expensive, but you can pay by instalments, or get insurance for each job in turn. The price of not doing this is very scarily high.Of course this insurance will count as a business expense, so you can count it against tax that you would be paying on the work.

Take Care Over Your Name

If you are going to give your enterprise a name, spend some time picking a good one. Practice saying the business name and make sure it sounds good to you. Think how it would sound to someone who rang you up. (I thought this was wonderful advice). See if you need to protect your name, and make sure that you are not using the same name as someone else, that could end really badly.

Get Help

You will need as much help as you can. Use skills from helpful family members, even if it is just as a sounding board so that you can make sure your ideas aren’t too wacky. There are lots of agencies who can help you find grants and all kinds of other things, starting with the Knowledge Exchange on the university campus. The Platform Expo folks in Hull are also a great source of resources, particularly if you need things like office space and help setting things up. Look up Microsoft BizSpark for free software.

One piece of advice that I heard from another source was that if you are not sure whether or not you need funding, you probably don’t. If you need money, for example to buy a new machine or some stock, you will really know that you need it. Don’t just think you need to get cash just so you can get started. If you have your trusty laptop, a good network connection and can afford to live, then for a developer that is probably all you need.

Do what you like

If your business is a success you are going to be spending quite a lot of time doing it. So try to find something you enjoy doing. If you have a hobby that could become a business, that is not a bad way in, either way, if you do it right you should avoid the “Monday morning feeling”. And maybe even become rich.

If you want to find out more, go here:

http://www2.hull.ac.uk/administration/enterprise.aspx