The Spam Fight Continues
More and more spam has been gradually getting past spamassassin and winding up in my inbox lately. It’s getting really annoying. So today’s project is to upgrade to SpamAssassin 3 in the hope that it contains some new voodoo that will clean up my inbox again. It seems to have a new requirement on Digest::SHA so this time the build can go through CPAN but it’s on to the tests now and everything seems okay. Hopefully it will be a smooth upgrade.
Globalization
Every so often an event happens that makes you realize just how globally oriented the world is today. I’ve been watching the results of the US presidential election over the course of the day, getting updates in real time. This in itself is nothing particularly special. The fact that I’m Australian adds a little to the sense of “globalness” but it really struck me when I realized that I was an Australian watching the results of the US election in real time over the web – via the British Broadcasting Corporation. I mean, it wouldn’t have been particularly surprising for me to watch CNN reports flow by my RSS feed about the US election, and it wouldn’t have been all that far fetched to think I might have a web page open that showed the results as they came in. It does strike me as odd that the page I happened to be pointed at for the results essentially formed a triangle that touched the furthermost parts of the globe. Such is life these days…
Trackback Spam
Sigh, while my comment spam avoidance measures seem to be exceptionally successful, I got hit by my first batch of trackback spam this morning. Nearly 100 trackbacks to various entries. Fortunately they were all for the same domain so MT-Blacklist could clean them all up in one hit. I guess I’ll have to rename the trackback CGI next….
Equals (Settled Once And For All)
Andraes Schaefer finally comes up with a solution to the great equals debate. It turns out that in fact it is possible to implement equals in such a way that it works well with subclasses that add additional constraints to equals.
Andraes’ solution is still not great though because of the restrictions he mentions:
- All sub class must overwrite and adjust the equals() method otherwise line 8 in the base class will create an endless loop
- The equals() method in the sub class cannot call the equals() method in the base class otherwise it ends up in an endless loop, too
- Line 11 in the Complex class cannot check against a sub class of Irrational in a different branch (meaning it is not a sub class of Complex, too)
I think we can solve the first two of those problems by throwing more code at it (I’m not sure we want to but I think we can). Here’s how, in the base class we have:
Hunka Hunka Burnin’ Office
You know it’s going to be a bad day when you get to work and discover the building surrounded by police tape with 3 policemen standing outside and the chairman of the board asking “when did you last do a backup?” You know it’s going to be an even worse day when your response is “since when have I been in charge of backups?” The restaurant above our office caught fire sometime Monday night, fortunately the fire brigade managed to contain the fire to the restaurant so our office only suffered minor water damage to one room. We were however without power for a day and a bit which was a bit of a nuisance but meant we didn’t loose any data or any time setting up systems again. On the downside, the air-conditioning still hasn’t been approved as safe and Brisbane is getting some really hot weather at the moment. Being in an office full of computers with no air-conditioning is proving to be not so much fun.
More On Exceptions
Benjamin still doesn’t like exceptions but I sense I’m making some headway.
Again, I think it comes to the number of paths through a piece of code. and much later:
Exceptions put a possible branch on every line of code, and that is why I consider them evil. It seems to be this belief that exceptions put a possible branch on every line of code that is making Benjamin dislike exceptions. Again though, this is just a case of exceptions making possible errors obvious. For instance, how many possible codepaths are there in the C code:
A Washing Victory
Until just recently, we haven’t had any real rainfall for quite some time. During such times, one tends to become rather lax about getting washing done because it’s just so easy to throw it on the line whenever and within hours of daylight it will be dry. Sadly, this went someone wrong for me on the weekend. I did a load of washing on Saturday and didn’t get around to bringing it in before the evening dew set in. I then did another load on Sunday and the rain set in just as I finished hanging it out. Sunday night and Monday was heavy rain and storms, this afternoon another storm is on it’s way in and rain is predicted for the rest of the week. Things looked bad for me having clean clothes to wear by the end of the week (I don’t own a dryer). Fortunately, leaving work slightly this afternoon paid off – I got home just in time to get my washing off the line before it started raining. And if you’re wondering why I’d post this here, it’s because I felt I just wasn’t airing enough dirty laundry on this blog…
Exceptions Are Your Friend (but so is garbage collection)
Benjamine Carlyle and I have been discussing exceptions. Put simply, he hates them, I love them. I think I know why now.
Adrian Sutton argues that exceptions are not in fact harmful but helpful. I don’t know about you, but I’m a stubborn bastard who needs to be right all the time. I’ve picked a fight, and I plan to win it ;) I’m also a stubborn bastard (just ask Byron about ampersands), so let the death match begin! Actually, as I mentioned in this case I think we’re arguing different things so we might be able to resolve this amicably. Benjamin’s biggest problem with exceptions is that code in between the throwing of the exception and the handling of the exception “gets hurt”. The answer here is called abstraction. Abstraction in this context has a very simple tenant: when I call a method, it does stuff and I don’t care how it does it. In other words, if I call the method doStuff(), I don’t care if an exception is thrown in a deeply nested function call or directly by doStuff, to me doStuff simply through an exception. This is then true for doStuff, it only cares about each method it calls and not any methods under that and so on. So for any given piece of code we only think about one level. Methods and classes provide abstraction. Now that we’ve abstracted things, there simply is no code left in the middle to get hurt. Each method should handle whatever exceptions it may cause in whatever way it needs to. It’s the whatever way it needs to that differentiates Benjamin’s viewpoint and mine. Benjamin has been talking about exceptions in C++ whereas I have been talking about exceptions in Java. In C++ when an exception is thrown you have to carefully sort out what memory you had already allocated and not freed then make sure you free it etc etc etc. In other words, an unexpected failure is catastrophic and pretty much unrecoverable. In Java however, it’s no big deal at all. Objects will happily be garbage collected when no longer required, it’s simple to tell if objects have been created and it’s also really simple to clean up any allocated resources. So in Java if we were working with a database, we’d do something like:
Exceptions Are Your Friend
Benjamin claims that exceptions are evil, he couldn’t be more wrong. Exceptions are in fact one of the best ideas that has been added to languages, particularly checked exceptions which force people to deal with error situations. Benjamin’s first problem with exceptions is that they’re impossible to test. This assertion is flat out wrong. Exceptions simply make you aware of a case that you’re not testing. For instance, say we have a function that writes to a file, as part of our testing we should test that it behaves correctly (ie: produces the expected behavior) even in situations when the file can’t be written either because of a lack of permissions, a full disk, missing directory, network error or hardware failure. It doesn’t have to work in those situations, but it must behave predictably because one or more of those situations will occur when the program is in production at some point or another. Without exceptions, the code might look something like (using some convenient but totally fictional libraries):
Anti-Anti-Anti-Smokers
(I’m upping the anti)
The next person that whinges about restriction of smoking to private homes will receive a free gift. Yes ladies and gentlemen I shall stand next to them, and share with them the gaseous byproduct of my digestive process. It�s my RIGHT isn�t it? Isn�t it? — David Jericho No it is not. Quite the opposite in fact. As part of your right to life, you have the responsibility to not interfere with the right to life of others. Since smoking reduces the expected life span of the people around you via passive smoking, you are interfering with their right to l’#8217;m sure you could also word that around having the right to not have people reduce your health’#8217;m not sure how to word it clearly and the right to life is a far better established right. As for the threat to share the “gaseous byproduct of my digestive process”, were it enacted, I would be forced to remove the fire hazard with extreme prejudice (and the closest bucket of water). UPDATE: er, clea’#8217;m an idio’#8217;m agree with David entirely. I guess I got confused with the anti-antiness of it all.
Burning Ubuntu Linux ISO On OS X
If you ever try to download, burn and install the Ubunto warty ISO image on OS X you’ll find that Disk Utility crashes and hdiutil crashes. To get it to burn you need to install cdrecord using fink (fink install cdrecord) and then use the information on this page to work out how to burn it. On my PowerBook G4 with a DVD-R/CD-RW drive I used the command: sudo cdrecord -v speed=24 dev=IODVDServices warty-rc-install-powerpc.iso and it’s working fine. We’ll see how it goes from here on in.
More Sex All Round
Iain points to this gem of an article. Some choice quotes:
Dr Greening and colleagues asked 42 men to ejaculate every day for seven days Excuse me Sir. Yes, sorry to interrupt – would you mind doing me a favor? Yes, I just need you to jerk off every day for a week. … Say, how’d I wind up in hospital again?
I think it’s exciting Don’t we all Dr Greening. Don’t we all.