The Daily Parker

Politics, Weather, Photography, and the Dog

Small classes (geeky)

Andrew Binstock, editor of Dr. Dobb's, has a pair of editorials in praise of and instruction to create small classes:

High levels of complexity, generally measured with the suboptimal cyclomatic complexity measure (CCR), is what the agile folks correctly term a "code smell." Intricate code doesn't smell right. According to numerous studies, it generally contains a higher number of defects and it's hard — sometimes impossible — to maintain. ...

My question, though, is how to avoid creating complexity in the first place? This topic too has been richly mined by agile trainers, who offer the same basic advice: Follow the Open-Closed principle, obey the Hollywood principle, use the full panoply of design patterns, and so on. All of this is good advice; but ultimately, it doesn't cut it. ...

...[Y]ou need another measure, one which I've found to be extraordinarily effective in reducing initial complexity and greatly expanding testability: class size. Small classes are much easier to understand and to test.

In Part 2, in which Binstock responded to people who had written him about the first editorial:

Coding classes as diminutive as 60 lines struck other correspondents as simply too much of a constraint and not worth the effort.

But it's precisely the discipline that this number of lines imposes that creates the very clarity that's so desirable in the resulting code. The belief expressed in other letters that this discipline could not be consistently maintained suggests that the standard techniques for keeping classes small are not as widely known as I would have expected.

Both editorials make excellent points. Every developer should read them.

Senior Software...Gardener?

Apparently "gardener" makes more sense than "engineer:"

So why do so many gardens fail, yet so many skyscrapers succeed? With a few exceptions, the technique for building a skyscraper is similar whether you are in Europe or you are in Singapore. Gardens do not work that way. Every garden is different because the environment it is in is different. Even gardens that are within throwing distance of each other can have wildly different soil. That is why the lowest bidder can probably build the same bridge as the highest bidder, but your company can’t grow the calibre of gardens that Google can grow.

Remember that time when someone in your company unsuccessfully used an Agile gardening methodology, and then went around saying that it was horse shit that doesn’t work? Well horse shit does grow gardens, it just wasn’t enough to save your garden. Your garden was probably dead before it started – a victim of the climate of your organisation. Were you trying to grow a rainforest in the desert? You can’t just plant the same plants as Facebook, Flickr or Twitter and expect them to take root regardless of the quality of your gardeners or the climate of your organisation.

(Hat tip MVT.)

On to plan B

One of the benefits Avanade provides is a fairly generous "technology" budget. I'm given cash, every year, to buy things that either demonstrate my (read: Avanade's) love of technology, or give me better work-life balance.

This week I bought a 240 GB solid-state drive for my work laptop to replace the 256 GB drive it came with. So, I backed up the entire drive using Windows 7 System Image, swapped the drives out, and...crap.

Did anyone else notice that 240 < 256? Yeah. Also, the bigger drive was bit-lockered.

So, yeah, I can't restore the image. I am now copying all the data I'll need and, in fits and starts this weekend, I'll be rebuilding the laptop from scratch.

Phooey.

Good thing I'm a Cubs fan

This may actually be funny.

My CCMBA class includes students from 30 countries, in every part of the world. Consequently, Duke has created a Flash-based Web portal, through which we take exams, submit assignments, attend classes, and keep in touch. The thing has worked more or less as advertised since we arrived in London two months ago.

By tomorrow at 23:59 EDT, we must hand in our Accounting and Management exams. We have 24 hours from download to complete the former, and 90 minutes to complete the latter.

Can you see where this is going? Of course you can:

See, as a Cubs fan, this doesn't bother me so much. There's always next year.

Update: Tech support just emailed me back. Apparently they had a hardware failure in one of the server rooms, and the infrastructure guys are on it.

Update, 13:30 CDT: The platform is back up. Here we go...let the exams begin.

Update, 13:35 CDT: They did a fu@!ing upgrade! During exams! Unbefu&@ingleivable.

Final update, 13:55 CDT: OK, it looks like they did a rollback to a known-working version of the platform, not a upgrade. That makes a lot more sense. I will just assume that, because it's exam week and I've had a little more caffeine today than usual, I might have some extra nervous energy that caused me to jump to hasty conclusions. I will now walk the dog, take some deep breaths, and start the first exam.

Hunting wabbits

(By way of explanation why I'm being wery wery qwiet today.)

Actually, I'm hunting financial accounting (Duke) and bugs (client). Like this one, which shows one of the perils of refactoring. See if you can spot my stupidity:

Original code

private void OldMethod
{
   bool canChangeThing =
   (
      _isCompany |
      _isClient &
      (
         someConditionA == true |
         someConditionB == true
      )
   );

   if (canChangeThing) 
   { 
      // do stuff 
   }
}

Refactored code

private bool CanChangeThing
{
   get
   {
      return (
         _isCompany |
         _isClient &
         !(null == _thing) &&
      	(
            someConditionA == true |
            someConditionB == true
         )
      );
   }
}

private void OldMethod
{
   if (CanChangeThing) 
   { 
      // do stuff 
   }
}

Fixed bug

private bool CanChangeThing
{
   get
   {
      return (
         _isCompany |
         (_isClient &
            !(null == _thing) &&
            (
               someConditionA == true |
               someConditionB == true
            )
         )
      );
   }
}

private void OldMethod
{
   if (CanChangeThing) 
   { 
      // do stuff 
   }
}

The sound you hear is me hitting my head on my desk until it stops hurting.

Baffling usability

The following photo shows a programmer, a usability expert, and an IT manager struggling to figure out how to add players to a bowling game using AMF's scoring software. I don't even remember the sequence we had to go through, but I do remember thinking (a) on average, we were sober; and (b) software that makes something so simple take so long should be punishable...in some appropriate way.

On the other hand, one doesn't go to a bowling alley because of the software they use. On the first hand, however, bad software makes everything less fun.

And yes, Virginia, Bengt (right) is wearing a custom-made bowling shirt. One of the other bowlers gave it to him for his birthday, which is how I came to be at a bowling alley, and sometime later that evening, at a seriously hard-core karaoke bar. Tambourines were involved, I recall...

Oy, mein altekaker Kindle!

Via Sullivan, I suddenly feel very old:

We extracted about 75 percent of the responses on age (representing about 700 responses, taking equally from the earliest and most recent postings, which show very similar age distributions). Per John Makinson's quip at an LBF panel, over half of reporting Kindle owners are 50 or older, and 70 percent are 40 or older.

So many users said they like Kindle because they suffer from some form of arthritis that multiple posters indicate that they do or do not have arthritis as a matter of course. A variety of other impairments, from weakening eyes and carpal-tunnel-like syndromes to more exotic disabilities dominate the purchase rationales of these posters.

Wait! I'm not 40 yet! And I see just fine, with a little help.

This, on the day that I took a final exam in a class (Introduction to Microeconomics) in which every other student was younger than half my age. Yes, there were about 50 of us in there, and the day the Berlin Wall fell down I was older than they are now.

Sigh.