Encapsulating Understanding In Code

September 18th, 2006

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.

Fortunately, we can write a single class that given a few simple parameters will handle every situation you ever need and give the right values every time. Even better, it comes with a suite of tests so that even as the code is modified and updated over time you can have complete confidence that it will still give the right answers. It's far less likely that a bad change will be made in those tests because they're small and focussed instead of just being an unimportant looking part of a bigger test. It's far less likely that the code will be changed because it is isolated from the rest of the system - it stands almost entirely alone just doing what it does best day in and day out.

In the last few months we've applied this principle, sometimes unknowingly, with a huge amount of success. The number of opportunities we've opened up for improving our product is pretty exciting, and it's made possible to see because we can now think at a higher level than before. We've got little digital assistants running around the product taking care of the details and we're becoming more like the grand conductor waving in broad strokes and creating beautiful music with every movement. Then of course we wander into an older part of the code base and get ambushed - just as a reminder of why we should continue to focus on improving quality at every opportunity and encapsulating what we know today so that we can learn more easily tomorrow.

Quick Java Puzzler

September 14th, 2006

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

September 14th, 2006

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

September 14th, 2006

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.

Sigh.

Enterprise Just Isn’t Exciting To Consumers

September 12th, 2006

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.

So Scoble, welcome to the world of enterprise - you'll find a huge array of cool stuff going on over here that makes businesses more efficient, better manages information and knowledge and generally makes big business work better. To find the latest buzz though you might want to try an old fashioned on-paper newspaper rather than just following blogs, at least until the "cool kids" work out where the really cool stuff is happening.