September 14, 2006
Quick Java Puzzler
While I’m waiting for Eclipse to do an update: What’s the one value you can pass to Math.abs(int) and get a negative value from?
Just ran into a bug caused because of it – fortunately it was picked up by the tests even before I checked in.
September 13, 2006
Setting Up A Fallback Font
This seems to be the simplest description of setting up a fallback font I’ve found: http://weblogs.java.net/blog/joconner/archive/2006/09/internationaliz.html
We occasionally come across clients with the problem of fonts not rendering correctly in the JRE so in future I’ll be able to point them to this article. Fortunately, with Java 1.5 a pretty good fallback font is already provided so it’s pretty rare that you need to do this these days.
September 13, 2006
Another Update, Another Broken Outlook
It’s reasonable enough I suppose, but annoying none the less. Everytime a new update comes down through Windows update, it breaks Office 2007 Beta 2 by “updating” some of its DLLs to older versions. Fortunately, the repair functionality in the office installer seems to fix it but it means waiting around for 15 minutes or so while it gets fixed. It would be nice if Windows Update checked that the file it is replacing is the one it expects to be replacing before going ahead – it would avoid all kinds of problems like this.
September 12, 2006
Enterprise Just Isn’t Exciting To Consumers
I find it somewhat amusing that Scoble is discovering the enterprise market at the SAP conference. One quote in particular stuck out for me:
SAP is no Web 2.0 business. The cool kids like Mike Arrington don’t follow its every move like, say, the way we follow Google or Microsoft. On the other hand, name the business and it probably runs on SAP.
Ephox is like that – tiny little company that no one seems to have heard about, but you name the big enterprise CMS and we’re probably in it.
September 11, 2006
Mocks Are A Sometimes Food
There’s an interesting pattern when you start doing TDD and trying to make your tests as atomic as possible1. First of all you wonder how anyone could ever get far with completely standalone classes that don’t interact with anything – obviously a program needs some level of communication between classes. Then you discover Mock objects. These wonderful little gems allow you to have communication between classes but still test them independently.
September 10, 2006
Stripping Styles As Part Of Sanitation
Somewhere along the line I stumbled across Mark Pilgrim’s description of how the universal feed parser sanitizes HTML. A key part of this is that the universal feed parser strips styles because IE on Windows can wind up executing part of that style as JavaScript.
While obviously at the moment this how to be done, it seems completely unreasonable to me that any content that wants to be syndicated accurately needs to avoid CSS entirely.
September 7, 2006
End To End Testing And The 10 Minute Build
At least in my mind, there seems to be a clash of aims in XP. You want to make sure that you have complete confidence in your tests so that you can go faster and reduce the cost of change. To achieve this you write lots and lots of tests – until your fear of something breaking turns to boredom from writing tests you know will pass. Most of those tests are atomic and test a particular component, but fear lies in the gaps between components too so you regularly get recommendations like Ola Ellnestam’s on my previous post, Testing Your Setup Code:
September 7, 2006
Refactoring To Make Improvements Possible
I’ve had an interesting experience the last couple of days – I’ve been trying to add some major new functionality into our list code. The code is exceptionally well tested and fairly easy to understand but it wasn’t clear how to write a test that described the functionality I wanted to add.
I started off by writing an acceptance test for what I wanted and then started drilling down to what I needed, but it was leading me off into a rewrite of our list code because it was too difficult to see how to reuse the existing code for what I wanted.
September 2, 2006
Another Thing To Dislike About Obnoxious Referrer Links
I complained before about Obnoxious Referrer Links and now Andy has stumbled across problems they cause in the real world.
It turns out that having a meme tracker for the feeds you subscribe to can produce some interesting results. The big issue is that some feeds either rewrite URLs to include a redirect through their server, or strip all HTML and just give you a snippet of the article. This makes it basically impossible to determine if two items link to the same article.
September 2, 2006
Stop Using Wikis As Documentation
A lot of projects these days have taken to using a wiki as a way to get the community to write the documentation for them. This appears to work really well with a huge range of pages being created telling you how to do all kinds of stuff. Unfortunately, for anyone who actually needs to learn about the project, these pages are about as useful as tits on a charging bull.
September 2, 2006
I Thought Rails Was Meant To Be Productive…
Why is it that a hugely database dependent framework, that’s meant to be extremely quick to get up and running with is so infuriating when it comes to get it actually talking to the database? I know cross-language interfaces are always difficult, particularly when you try to make them work cross platform but if I can get Java, PHP and perl all talking to MySQL easily, why does it have to be so damn hard for ruby?
August 30, 2006
Ternary If Hiding Duplicate Code
I realized an unintentional side effect of deciding to not use the ternary if (a ? b : c) – there’s a bunch of code that we don’t duplicate that we otherwise probably would have. In particular, when working with views there’s a very common pattern to convert between a Shape and a Rectangle1:
Rectangle bounds = shape instanceof Rectange ? (Rectangle)shape : shape.getBounds();
The reason for this is that getBounds() on a Rectangle will create a new Rectangle instance so if you happen to be getting the bounds a few thousand times every time you go to paint the text pane, you generate an awful lot of useless rectangles.