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
Friday
May172013

How to Fail your Assessed Course Work

sunset 006.jpg

First a note. We don’t have many people that actually do fail their coursework (although, years ago I did manage it by using a variant of this technique involving punched cards). But over the years I’ve seen enough of these to be able to produce a comprehensive guide. This is the sequence that I have found works very well when it comes to failing a software development project. Just follow this fool proof set of instructions for guaranteed failure.

  • T-minus 8 weeks: Assignment distributed. Decide to ignore it for now. Put on desk.
  • T-minus 4 weeks: Happen to find assignment under pile of dirty socks. Take a quick look. Seems easy enough. Decide to do it later.
  • T-minus 2 weeks: Find the assignment again and experience a mild twinge of panic when you look at the submission date. But no time to do it because other coursework is due in now.
  • T-minus 1 week: Decide to complete entire program by performing herculean development effort over the coming weekend. Feel much better. Go to pub to celebrate.
  • T-minus 2 days: Fire up Visual Studio and write 300 lines of code in one sitting. Which won’t compile. And actually you’ve no idea what it does. Stay up until 2:00am trying different combinations. Ask a chum who has just come back from the pub to take a look. He suggests adding a bunch of curly brackets and semi-colons. Code now compiles and runs. But you still have no idea what it does. Fall asleep at desk and wake up after six hours with key shaped bumps in your cheek.
  • T-minus 1 day: Program now fails to compile again after you pasted in some code that you found on the internet that looked like it might do what you want. Decide to seek help. Post a plea for help in a question on Stack Overflow.
  • T-minus 12 hours: Check Stack Overflow for answers. “SuperDev99” thinks you should use recursion. “P-Guy” thinks you should really use Python. “Troll95” posts that all C# developers are ugly and stupid.
  • T-minus 6 hours: Having had no sleep for 20 hours you decide to re-write the entire system from scratch. It seems like the only way. You write another 300 lines of code. That won’t compile.
  • T-minus 1 hour: Program now compiles, but it is alternating between crashing instantly and causing the computer to lock up. Check Stack Overflow again. Find that someone has posted a complete solution to your problem. In Prolog.
  • T-minus 10 minutes: Submit program that compiles, runs and prints “Sorry about this” in large friendly letters on the screen. Oh well. There’s always the resits.

Now, of course, nobody actually does all of this. Although I’ve managed most of these tricks at one time or another. Please, please, if you get some coursework, frontload it. Have a crack at the code as soon as you receive the specification and then play with it in the run up to the due date. You don’t have to write all the code at once (in fact this is a bad plan) but you should keep noodling along with the system over the weeks leading up to the hand in. And seek help if you hit problems.

The internet is often very useful, but beware of using downloaded code. Often you end up trying to use some code you don’t understand to solve a problem you don’t understand and getting errors that, wait for it, you don’t understand. Much easier to take your problems down to the lab or to the person in charge of the coursework and get them to help. If you want to post questions, use the forum or departmental Facebook group. At least the folks there will have an inkling of what you are doing and why.

By the end of my university career I was getting reasonable marks for coursework, and this was mainly down to a “starting early” technique.

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.