Encapsulating Understanding In Code
In most software projects, there are a few areas that are just really complex to get your head around. It’s not something that refactoring can solve, the underlying concepts are just difficult to work out. Fortunately as software developers, we can learn that information once and encapsulate it in code that will understand it for us and even apply it in new situations that we didn’t originally consider.
Recently, we’ve developed a really neat, simple example of this – the PushAndPopCalulator. A surprisingly simple class that determines the appropriate values for popDepth and pushDepth when inserting in Swing text components. The push and pop depth is a way to manipulate the element hierarchy of styled documents to precisely determine where the inserted content works out. Once you understand the details, it’s a reasonably simple concept but working out exactly what values you need for a particular insert requires a break in focus on the actual problem to divert into working out details of using the underlying APIs. It takes a little more time to generalize that to cover all the possible situations you might need.
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.
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.
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.
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. We have a client list that most companies would kill to get their hands on and unlike most Web 2.0 businesses – we not just burning VC.
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. Pretty soon you’re going on a cookie monster style binge session with mocks. Everything can should and will be mocked out and there’s no longer any need to worry about making your classes keep to themselves, all those external dependencies can just be mocked out.
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. It seems to me that rather than stripping style information, we should be pressuring Microsoft (and any other affected browser vendors) to fix the browser so that it doesn’t ever treat information in CSS as executable code.
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:
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. In the end, I decided to almost reverse refactor the existing code to extract out the logic that I needed. I say reverse refactor because instead of making the code simpler to read and understand, it was making it more complex – it really felt quite wrong to be applying the refactorings.
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.
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.
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?