Entries Comments

Alex Mace’s Blog

Life & Web Development

Royal Mail Online Postage

shipment_of_failRoyal Mail’s Online Postage used be a great service. In a nutshell, it allowed you to pay for posting something online. Once you had paid, you could then print out an envelope or label and pop it in the post without having to get a book of stamps or visit the Post Office. No mess, no fuss.
For Mac users, that was the happy situation up until fairly recently, when Royal Mail “upgraded” their offering and completely broke it.

You see, when you download your label, it comes as a PDF with “SAMPLE” in large, unfriendly letters across the front of it and a small box explaining that this wouldn’t print out on the final label. Which was true, whether you were using Adobe’s official PDF viewer, Adobe Reader or Apple’s Preview, which ships with Mac OS X and doesn’t come with a load of crapware attached (Adobe Air? Acrobat.com? Fuck off Adobe). However since Royal Mail “upgraded” the service, if you print the label in Preview it also prints the unfriendly “SAMPLE” and the notice that it won’t print the word “SAMPLE”.

So you have to use Adobe Reader instead. However this doesn’t work either, as I found out. Not only does it force you to install other services that I didn’t want (Still here Adobe? FUCK OFF), but when I first launched it, it halted to install updates. That’s right, updates on software I just downloaded and installed. Then, say for example you told Royal Mail you wanted to print out a DL envelope. Well Adobe Reader can’t manage to print that out for you. Instead, it assumes that the envelope itself is A4 and scales it down to fit on the envelope. Which it then fails to print on, only managing to fit the top 25% of the label on the bottom of the envelope, rendering it useless.

So congratulations Royal Mail. You’ve taken a useful, if little known, service and rendered it useless for me. I guess I should be thankful you haven’t closed the Post Office at the end of my street.

The iPad Buying Decision

While the iPad is now available for pre-order over in the US, the date when you can do the same in the UK has not yet been announced. There are some questions to be answered: What will the UK pricing be, should you buy one and if yes, what model should you get?

Up until fairly recently, Apple were displaying the US prices on their UK site, with a note that international prices had not yet been announced. This, to me, seemed a strange move for Apple considering their UK prices have usually been substantially more than the (US price * exchange rate) + VAT. Perhaps for once they were going to actually do that, but since the initial announcement of the iPad sterling has slipped considerably against the dollar, which I think was what prompted the removal of the US pricing. They are, however, still trailing it as being available at a “unbelievable price”. Unfortunately for those of us in the UK, this is more likely to be unbelievably high than unbelievably low.

These are the current US prices:

16Gb 32Gb 64Gb
Wi-fi $499 $599 $699
Wi-fi + 3G $629 $729 $829

Current US prices in sterling at current exchange rate (£1=$1.517):

16Gb 32Gb 64Gb
Wi-fi £329 £395 £461
Wi-fi + 3G £415 £480 £546

What I expect sterling prices to be for the iPad:

16Gb 32Gb 64Gb
Wi-fi £399 £499 £599
Wi-fi + 3G £499 £599 £699

It is very much possible that they may be higher, they may be lower. I have no insider information, but on past evidence I would expect prices to be at least those I have listed. There is precedent for worse; Apple TV is available in the US at $229 (£151 at the above exchange rate) but its UK price is £223.

Anyway, regardless of that, which iPad should you buy? Let’s start by thinking about which model to go for – Wi-fi or Wi-fi + 3G (which I’ll refer to just as the 3G model after this point to prevent confusion). I personally think it is unlikely that the iPad’s main use is going to be going on the Internet while on the move, that’s what the iPhone is for. So you could make the case that you don’t need to buy the 3G model. However, the 3G version also has GPS, which to me is justification to spend the extra money on that model. The 3G chippery itself is a mere bonus. The possible applications of GPS in location-aware apps is very exciting and I wouldn’t want to be excluded from that. So get the 3G model.

Next question is how much storage should you go for? When buying a hard drive, my advice is usually to think about how much you need and double it. My 16Gb iPhone is full and only has one movie on it. The iPad is going to be a million times better for looking at photos and watching movies, which will require much more storage. Better to be able to take as much as possible with you rather than wishing you’d put movie x on rather than the selection you brought with you. So I’d go for at least 32Gb, preferably 64Gb.

Does that mean if you can’t afford the £699 top of the range 64Gb 3G model, you shouldn’t get one? No, it doesn’t. If you want one, get the one you can afford, but I’d go for the 16Gb 3G model before looking at the 32Gb Wi-fi model because it gives you more possibilities with it’s GPS. You can always swap around your content if necessary, even if it is a bit of a faff. You can’t swap the features around.

So, am I going to buy an iPad? No. Not yet anyway. At the moment the iPad doesn’t offer me enough to justify getting a device between my iPhone and MacBook Pro. It’s close, though. I suspect the mark 2 iPad will have a forward facing camera, which will make it a great device for video conferencing and all the stuff the mark 1 can do. Roll on the 2011 model.

Where Should Data Be Validated In Objects?

Last week in work we were talking about data validation when working with data inside objects. We are currently in the process of replacing a lot of old, procedural code with OOP style code. When objects perform operations, they need to have certain data to work with and we need to have a way of handling situations where those objects do not have all of the data that is needed.

I think the data being used falls into three different categories and you can place different levels of trust on those categories. The first is user submitted data. User submitted data should not be trusted one bit. While 99.9% of your users may be trustworthy people, it only takes 1 curious or worse, malicious, person to start sending you unexpected data to cause you a major problem. The next category is data that has come from outside the current block of code. This data should be moderately distrusted, since you are assuming that whatever process gave you that data has set it correctly. To err is human and since software is written by humans, it is natural that software will err too. So it would be sensible to check that data is at the very least reasonable before proceeding. Finally there is data set by the current block of code. It would seem sensible to trust this data. You can see where it has come from and know it’s possible value. No need to spend a lot of time checking the value of it.

Now, what if any of this data is wrong? My original thoughts on this was that the objects should check the data on use and throw an Exception in all cases. However, the procedural code would have told the user about all of the data that was missing. Using Exceptions, you can only really deal with one piece of data at a time. You could concatenate errors and then throw an Exception afterwards, have nested catch statements, etc, etc, but those solutions have a bad code smell to me.

Another suggestion made was to use a validate function within each class. On the face of it, this solution seems pretty good. We can use this function externally to validate the data and display errors to the user and we can use it internally to make sure that the operation has all of the data that it requires. This solution does not hold up well under scrutiny. As a colleague pointed out, the validation function would need to know which operation it was validating, leading to various switches and control structures within the validation, more maintenance and ultimately bloat. You can also end up with duplication of validation if you do more than one operation that uses the same data. Each operation would have to validate its data; data that may have already been validated previously. Sure, you could mark that data as safe internally, but I think that by that point that you are solving problems that you should really be having. Additionally, I believe that classes should be working with data, not on data. So that wasn’t going to work either.

With some further thought, I decided that really, Exceptions shouldn’t be used at all for errors that end users need to be informed about. Data from users should transformed, through filtering, sanitizing and validation, into the second category of data, before asking the object to perform any operations. If something is then missing when the operation is called, it should throw an Exception. If the data is then missing at that point then something serious has gone wrong and the program should not proceed any further.

So there you go, in my personal opinion, objects should not be validating data submissions. They obviously do need to check that they have the data they require for the operation being performed, but that should throw an Exception on an error condition to prevent any further processing occurring. Web sites have an advantage in that they are not continuously running programs – each request and submission of data is a discrete operation. This provides you with a good point to filter, sanitize and validate your data, at the very start of your scripts. Use that advantage and check your data at the earliest opportunity.

My letter to my MP, Michael Foster

We had a letter through the door from our MP, talking about Worcester City Council’s proposed (and I believe, now approved) cuts on CCTV. I’d provide a link to the contents of the letter, but it doesn’t seem to be on his website. Anyway, here is what I wrote in reply.

Mr Foster,

Thank for you for letter regarding the CCTV situation in Worcester. I will be filling in the survey and returning it to you shortly, but I thought I would take a few minutes to give you my thoughts regarding some of the points you made in your letter and related issues.

The overall impression given in the letter is that the camera will no longer be there and that we will be less safe without them. You say
that you have “seen the statistics showing arrests made thanks to CCTV evidence”. Neither of these points are particularly informative or
helpful to me. If you have seen the statistics, I think it would have been useful to put that information in your letter, so that I and
others receiving it could make a more informed decision. Without that information how am I to know whether or not manning the CCTV
monitoring room is a cost effective use of council resources?

Which brings me to the second point,  the use of CCTV as a deterrent. Before writing to you, I thought I would take the time to look at the news stories on the issue, to make sure that I was fully informed. None of them say that the CCTV cameras will be taken down, or that
they will no longer be recording. They say that they will no longer be monitored. If this is true, then the deterrent benefit is still there
because the evidence will still be stored.

It saddens me greatly that the image that you portray in your letter is one where we all need to be watched, constantly, to ensure our
safety. Technology and surveillance are not a panacea. The only long term answer to our society’s problem is education. Knowledge is a
shining beacon against ignorance. By informing the young they will grow up to be thoughtful, intelligent people. I would far rather my council spent it’s money on educating the people of Worcester than watching them.

I really do not think that it is the “professional” criminal that makes people feel unsafe in our city. Rather it is the things that CCTV cannot prevent, merely observe. Things like vandalism, drunk and disorderly people, gang violence, etc. I am not surprised that you do believe that it can stop these things with CCTV though, since you are a Labour MP. I find the Labour Government’s cavalier attitude to putting us all on databases and giving us ID cards, so you can track our every move very disturbing. I know the argument, if I’ve done nothing wrong I’ve got nothing to fear. What if the Government does something wrong and gets me confused with someone else with the same
name. How can I argue against the system? Our civil liberties have been hard won and no one deserves, as you voted to allow, to be locked
up for 42 days without charge, even if they are a “terrorist”. Who decides tomorrow who is a terrorist? Could it be someone who disagrees with you?

Which brings me onto my final point. I find it deeply distressing and abhorrent that you raised the 2005 terror attacks in London as a reason to support CCTV. In this case it neither prevented the crime, nor caught the people involved. They had blown themselves up, along with 50  other people. CCTV could not save those people. CCTV will not comfort the people who lost loved ones. The warm glow of the CCTV monitor will not put any warmth back into those people who died. You should be ashamed.

Yours sincerely,

Alex Mace

Styling buttons in Firefox

This is more of a note to remind me in future. Take this bit of HTML:

<button><span>Save</span></button>

If you set the button and the span to have padding: 0, Firefox will still show the button with some padding. You can get rid of this with the following CSS:

button::-moz-focus-inner {
    border: 0;
    padding: 0;
}

Sorted!
 
 

iPhone 2.2

The latest update to the iPhone came out today. I’m not going to go into all of the new features implemented in the latest version, you can find out about them all here. I do have a comment on one change though. In Safari, why have changed the address & search box from having a line each to now being crammed into a single line? While this does free up more space on the page, I’m not especially interested in the content of the page while putting a new address or search terms. That’s annoying.

Other than that, I’m hoping that 2.2 will cure the crashes of Safari and Facebook that I’ve been encountering. Safari will sometimes crash when scrolling through a big page and Facebook just crashes randomly sometimes. I haven’t noticed either crash since I updated, but I haven’t used it that much today. I’ll comment back on how I get on.

3 Entries – 1 Year

It’s been a quiet year on this here blog. To be honest, I just haven’t had the time or inclination to write anything of particular note on here. There are reasons for that and I’m hoping that by dealing with them now I’ll free up time and head space for this place again. I know that I’ve said similar before and a lot of other people have gone for a long break, said they’ll post more often and then disappear again, but I do not plan on actually delivering on my plan this time.

Anyway, this evening Katie & I watched “The Assassination of Jesse James by the Coward Robert Ford”. It was a very long film, but I enjoyed the breathing space this gave to the story. It was a great film to watch on Blu-ray too, which helps. It reminded me a little of “The Talented Mr Ripley”, only much better because I actually enjoyed it…

Bargain of the Week

One of the problems with my current car (a 1992, 150k mile Mercedes 190E) is that the radio won’t pick up FM, which renders all the various FM transmitters I have for iPods useless. I’ve been looking for a cassette adapter for a little while and on Saturday I saw one in Tesco for £6.97. Considering Maplin in Worcester didn’t seem to sell them and PC World sell them for a ludicrous £14.99, the Tesco price seemed like a great deal.

However, I’ve just done a quick search on Google Product Search (sidenote: which is a terrible name compared to its previous name, Froogle) and I apparently could have got one for 79p. Damn.

…and we’re back

Ok, so my site has been offline a little while. I fell out with my host when it proved to be a pain the the arse to set up a regular payment via PayPal and couldn’t be bothered to find another one in the short term. So for now, this site is being hosted on a box in my house. It’s not exactly a powerhouse, being a silent little EPIA SP based machine, running at a mighty 800Mhz, but that should do for now.

In the short term I plan to evaluate what blog software is out there at there at the moment and possibly switch from Wordpress. I also want to transistion from using this domain name (whythehell.co.uk) to alexmace.co.uk and setup proper redirects.

Free to a Good Home (plus P&P)

Kate and I are in the process of buying a house, so we’re having a good clearout. We’ve got a load of books and videos to get rid of, so any of the following are free to a good home if you cover the P&P or come and collect. Leave a comment if there is something you want.

Books:

2006 Big Road Atlas
A History of the Modern World
A Tale of Love and Darkness
Accelerated C++
Accidental Empires
American Jihad
An End To Suffering
Anna Karenina
Bravo Two Zero
Business at the speed of thought
Cardinal of the Kremlin
Damon Hill:Grand Prix Year
Delia Smith’s Cookery Course Part 2
Detox
Families & How to survive them
FHM Presents: Bar-Room Jokes
Gaia Peace Atlas
Great Expectations
Guinness Book of Records (1987)
Harry Enfield and his Humorous
Home Networking Bible
How to turn your ex-boyfriend into a toad and other spells
If Chins Could Kill:Confessions of a B-movie Actor
Instant Web Scripts with CGI/Perl
Internet 1997 Unleashed
Introduction to Windows 98 Programming
Lorna Doone
Madame Doubtfire
Making of Star Trek: First Contact
Nintendo Choose Your Own Adventure Book:Flown The Koopa
Official Guide to Command & Conquer
Organizational Behaviour (4th Edition)
Patriot Games
Perl 5 Quick Reference
Personnel & Human Resource Management
Pride & Prejudice
Princess
Sex: A User’s Guide
Sons & Lovers
South Wales A-Z Road Map
SSN
Star Trek: Ashes of Eden
Star Trek: Covenant of the Crown
Star Trek: Federation
Star Trek: First Contact
Star Trek: Generations
Star Trek: TNG Technical Manual
Star Trek: TNG: All Good Things
Star Trek: Voyager: Caretaker
Star Trek: Voyager: Cybersong
Star Wars: Ambush at Corellia
Star Wars: Assault at Salonia
Star Wars: Children of the Jedi
Star Wars: Darksaber
Star Wars: Episode I: The Phantom Menace
Star Wars: Showdown at Centerpoint
Star Wars: The Crystal Star
Student Grub Guide
The Age of Innocence
The Book Thief
The Concise Encyclopedia of Formula One (2001)
The Crystal Maze: Choose Your Own Adventure
The Curious Incident of the Dog in the Nighttime
The Driver’s Little Instruction Book
The Hunt for Red October
The Jungle Book
The Last of the Mohicans
The Machine Gunners
The Mystery of Banshee Towers
The Portrait of a Lady
The Road To Nab End
The Simpsons:A Complete Guide To Our Favourite Family
The Star Trek Encyclopedia
The Star Trek: TNG Companion
The Third Policeman
The Ultimate Encyclopedia of Formula One (1994)
The Worst-Case Scenario Handbook: Dating & Sex
Why Pandas Do Handstands and Other Curious Truths About Animals
Winnie Ille Pu (Winnie the Pooh in Latin)
Women in Love
Women who run with the Wolves

Videos:

A Life Less Ordinary
Bagpuss
Beavis & Butthead Do America
Best of British: Mini
Clarkson: No Limits
Dirty Dancing
Ducktales The Movie: Treasure of the Lost Lamp
Fergie’s Six of the Best
Fever Pitch
Gone with the Wind
Harry Enfield:Undressed
Independence Day
Man Utd unauthorised: Whose Club Is it Anyway?
Manchester United on Video:Volume 2 Number 1
Men In Black
Muriels Wedding
Murray’s Magic Moments
Patsy Palmer’s Club Workout
Pride & Prejudice, BBC Version
Priscilla, Queen of the Desert
Red Dwarf Series 3: Volume 1
Red Dwarf Series 3: Volume 2
Robin Hood: Men in Tights
Shakespeare in Love
Star Trek: First Contact
Star Trek: Generations
The Very Best: Ryan & George
They Think It’s All Over: Full Throttle
Twister