JPod

I recently finished reading JPod by Douglas Coupland. It was a pretty strange book. The only other Coupland book I’ve read is Microserfs, but that was probably most of a decade ago so I can’t remember if that was nearly as weird. While the plot is ok, the ending is pretty weak.

The presentation is interesting (strange): there are pages containing the first million digits of Pi with one mistake to find, pages full of numbers where one zero has been substituted with an O, random words in huge fonts on pages that serve to divide it into chapters of sorts. These artsy things waste so much paper that the book is an astonishingly fast read given its heft.

The strangest part of the book is the level of narcissm on Coupland’s part. (Perhaps since this is on my blog I can’t really talk). At the beginning Coupland appears to grind an axe by having his characters declare that Melrose Place was a ripoff of his book Generation X and that the ripoff was so blatant as to be “actionable”. After that the characters refer to him occasionally, but that’s just leading up to Coupland appearing as character at least nine different times. The ending even revolves around him. I’ve seen authors give themselves cameos in books before (Cussler in particular I remember happening to be yachting around when his characters needed help), but this was pretty over the top.

Working on an anti-pattern

The project I’m working on right now is a collection of anti-patterns and just plain terrible code. The upshot of this is that its really hard to make it worse, and often times I can walk away feeling good about making a huge difference in making even small changes. My first project appeared well designed, and since I was new then, I felt very constrained in how much I could change. Not anymore, its like the wild-west in this code base, and any design is better than no design. Its definately been a good way to bust out of my years-long productivity slump.

The project was was started several years ago by an offshore contracting company (it seems like they got paid by the line) and then picked up by an in-house but still offshore team to continue to maintain and build. I don’t want to paint all offshore software-industry workers with the same brush, but in this case the code all appears to be written by people who just know how to program in Java. Barely. They just don’t think like computer scientists. For some reason no one seems to think a single class having five methods to do the same thing is bad. Or methods that are hundreds of lines long. Or building strings by concatenation, multiple times in loops that run thousands of times. Or checking for duplicates when copying the keys of a Map into a list. Converting Longs to Integers via a string object.

I’ve speculated that the current team must have come from a background of sustaining enginering (where the idea is to fix bugs in the least intrusive way possible) and that’s why they blithely copy the bad code around them. Either that or for some reason they don’t feel empowered to make changes.

The last few days have been especially great. I’ve been working on performance problems, and the code is so badly written that there are huge chunks of fat to chop out. Two methods I’ve found are O(n^2) so the profiler practically slaps you in the face, but they’ve somehow sat there for years. Replacing them with real implementations has reduced the time to run this code by 90%. Hours to minutes for large sets. That’s fun to talk about in meetings.

Where are the headless macs?

Todays release of the whopping 24 inch imac renews the question: why isn’t there a midrange headless mac, something between the mini and the pro? Like the Imac hardware, but without the built-in monitor and capable of driving two screens? It just seems like a shame to have a nice 24 inch LCD that will probably be useful for years after the computer attached to its behind is obsolete. I guess it’ll always be able to play movies.

Ode to unit tests and course-grained objects

I recently became a believer in the value of unit testing. I sort of understood the benefits of the test-first approach academically, but always felt that what I was writing would just be too difficult to unit test (UI stuff etc). Before this, ed I think the last thing I unit tested in a formal, framework using way was this directed acyclic graph thing I knocked out for workplace. This project dropped the prospect of taking in a pile of data and at the end spitting out some numbers, which would be easy to test, but that’s not what got me there.

The former code that did similar functionality (ok, really the entire project) is a tangled mess of collections of fine-grained value objects that mostly map to rows in tables. So a given section of code may be juggling three arrays and repeatedly iterating (where did i put that one?) to find objects that relate to objects in each of the other arrays. This is obviously inefficient and very hard to read (especially when the objects passed around have fields that are overloaded, their values depending on the computation phase as they are passed around in a disgustingly procedural manner), so I proposed taming the colections with more intelligent, course-grained objects that would serve as indexes of sorts. Now, instead of looking through the array (or several) to find the sales for item X at store Y the code could just ask an object “get me the data for item X at store Y”. Even better if there’s some kind of normalization or reduction of the data, it can be done as the object is filled with the value objects. So this presents a perfect unit testing specimen, because I can fake up some value objects, toss them in and then test what comes out, with and without manipulation.

None of that is rocket science, but it does allow two things: significant complexity can be hidden and thoroughly tested without hooking it up to an app server (fixing something in a JUnit harness is much faster than redeploying to the app server), and secondly that the code to actually do the final calculations can be astonishingly easy to write, read and integrate into the application. Indeed, in this case, the code slipped into place with only one bug.

From the outside, it seems like a lot of extra work to mock out supporting objects and write tests, but having done it it I feel like it saved me several days of total development time. The end product is better too. I’m not sure I can get behind actually writing tests first, but writing tests (in parallel in my case) definately helps to crystalize my thinking about what my objects actually need to do.

Shifty serving sizes

Shifty serving sizes

General Mills (secretly? sneakily?) altered the serving size of the multi bran chex I eat for breakfast. Instead of 190 calories per serving now its 160 calories. It just seems disengenuous that any food should be made to appear better for you by altering its serving size. Then again, does anyone actually eat just one serving of cereal? More mysterious is that the requisite 1/2 cup of skim milk factored in didn’t change. Do people suddenly like a higher milk to cereal ratio?

I see the benefit (to not eating too much, not so much the environment) of smaller individually packed serving sizes because there’s a certain mental barrier to opening another bag, but not the benefit of arbitrarily reducing the serving size.

30 Days

I really like the Morgan Spurlock created show 30 Days. If you’re not familiar, Morgan Spurlock is the guy who made Super Size Me, and he’s extended that type of stunt documentary to create the series. People spend 30 days in someone else’s shoes to better understand other’s lives or the other side of a polarizing issue The first season included Spurlock and his fiance spent 30 days living on minimum wage, a christian living with a muslim family, and a homophobic man living with a gay man. This season has had an atheist living with a mega-church-attending christian family, an anti-immigration minuteman living with a family of illegal immigrants, and the finale will have Spurlock going to jail for 30 days.

The iTunes music store has both seasons of the show avaiable for sale. The powerful illegal-immigration episode and a making-of the jail episode are available for free.

Time for a new phone.

Phone going south

My trusty Sony Ericcson T637 is in the process of shuffling off this mortal coil as you can probably tell from the picture at right. I’m looking around for a new phone but not seeing anything I really like. Cingular seems to be overrun by Motorola phones, and I’ve never liked their interface design. Their cell phone selection seems to be influenced by some echo of Henry Ford. You can have any phone you like as long as its a Razr. In four colors!

I want something that’s not really a smart phone, but rather a “smarter” phone. I don’t want a whole computer to carry around, but it would be nice if it had a basic HTML browser so I could use it with Backpack or some other online organizer. Perhaps some basic calendaring and organizer capabilities. It has to play nice with isync. Music playing and picture taking aren’t priorities because I already have those covered. Hopefully it’s not huge either.

I tend to overconstrain problems so that they can’t be solved, so maybe I’m already there with the above needs.

The Nokia Nseries looks like it could be a winner for me, but I don’t know if or when cingular would offer one of their phones, plus only the top of the line appears to support GSM850. They do offer the 6682 which appears to meet my needs, but they’re not doing me any favors; at $250 its only 50 bucks cheaper than getting it directly from Nokia, unlocked.

I like sony ericcson as well but I can’t decipher their current phone line and cingular only offers one of their phones right now, the Z525a, which doesn’t meet my needs. The k790 and w810
look like they could meet my requirements as well, but they’re not on Cingular yet either, although they are rumored to be showing up soon.

I guess there’s always ebay, but that’s complicated slightly because I have an AT&T; sim card rather than Cingular, so all the Cingular locked phones there will probably not work.

Suggestions anyone?

“Unimaginable” overused?

Lately in the news I’ve been struck by an overuse of the word “unimaginable”. Lets take a look at some examples. The first time I noticed this trend was in coverage surrounded the foiled not-even-close-to-execution plot to take down planes with liquid bombs. Here’s a quote from Deputy Commissioner Paul Stephenson of the Metropolitan Police:

… It is a very, very serious plot… Put simply, this was a plot to commit mass murder on an unimaginable scale.”

Next I saw an article in the metro (I can’t find the original quote) talking about how the returning student population was stressing the road system on top of the problems with the big dig tunnels, that one flat tire or accident could cause “unimaginable gridlock”. Searching for this article in google found this quote from a fiction excerpt instead:

The camera switched to an aerial view recorded earlier showing a scene of unimaginable gridlock stretching to the horizon in all directions.

Which is ironic, because given an aerial view, one doesn’t even have to use imagination! Another example of this use is about the evacuation preceeding hurricane Rita:

The evacuation triggers unimaginable gridlock, which in turn sparks anger, exhaustion and confusion

My final example comes from the public editor’s column in todays New York Times. The article is on the accuracy of polling data, and this quote is at the end of a paragraph on false precision.

The survey would have to interview unimaginably many thousands for that zero point eight to be useful.

I wonder whether these seemingly incorrect uses of the word unimaginable are a failure of vocabulary or of imagination?

Let’s revisit those quotes:

“mass murder on an unimaginable scale”: I can certainly imagine mass murder. In fact I don’t have too, because I could read about Hitler or Stalin. Blowing up ten airliners would kill three thousand people give or take. The death toll at the world trade center was 2,752.

“unimaginable gridlock”: I’m pretty sure I can imagine lots of cars waiting to go someplace, slowly.

“unimaginably many thousands”: I can imagine lots of thousands. How’s a million thousands. In fact in a survey, one could actually calculate (imagine that!) how many thousands it would take to have precision down to the tenth of a percentage point. Got math?

Time for some imagination.

US Centers of Population on a Google Map

I found a document (pdf) on the US Census Bureau site with data on the mean and median population centers of the United States over time. Unfortunately they didn’t stick it on a map so one can get a real sense of the slow south west migration. Fortunately this provided me with a good excuse to learn the google maps API and put the points on a map.

I’ve put the maps up here. I’m not sure I expected the median and mean to be so similar (though unfortunately there’s a hundred years less data for median). The mean ends up further west than the median because the distance of the west coast amplifies the weight of its population.

I was actually looking around the US Census site looking for some interesting data to build a Treemap with, but didn’t find anything yet with a two level hierarchy that didn’t end up at the county level. Got any ideas of something that could be interesting in treemap form?