Some pair programming success

I got to do some pair programming with a co-worker yesterday, about which I'm ecstatic. Sounds like he enjoyed it too.

"Righteousness and peace"

How many times have I begged and pleaded, spoken and written in the media, that peace must be obtained; that we begin to make a break with the killings and the evil, that we become the human beings that we are, and behave as men of faith in the one God of justice, truth and peace who calls us to righteousness and peace, but whose call goes unheeded.


—Patriarch Pavle of the Serbian Orthodox Church, in a letter to Islamic leader Reis-ul-ulimi Jakov

From a compilation of several statements, prayers, and appeals of Patriarch Pavle.

Is your design on the right track? Remember "PC-COF"

Testable Software Design:

Here’s my current definition of a testable system:

For each logical part of the system, a unit test can be written relatively easily and quickly that satisfies all the following PC-COF rules at the same time:

  • Partial runs are possible
  • Consistent results on every test run
  • Configuration is unneeded before run
  • Order of tests does not matter
  • Fast run time

—Roy Osherove via Keith Ray.

Waiting to refactor

There's a slightly tangled area in the code of my current project. It's an aspect of the code that hasn't needed much flexibility to support the existing features, so this being an agile project with gradual design, the code isn't very flexible yet.

And then the request came to add several new features that would exercise the currently-inflexible code. Panic! At this point I'm not even sure what exactly is wrong with this code, only that I have been struggling uphill somewhat every time I set out to use it. It's a little research project each time.

So I pour out my heart to my boss and the team member who's in the Customer role (it's an internal project, he really is the customer). "Oh boss, danger! There's something slowing me down, I know not exactly what, but I shall surely need extra time, etc.!" Too bad I let my fear run wild there. If I'd have had more patience and courage, everything would have been fine.

I wound up simply keeping one eye on the "problem" area of the code while I continued to make forward progress on the new features. Turned out there were two problems I was smelling, 1) a longish.message.chain in violation of the Law of Demeter that was causing coupling problems, but only at 2-3 sites, and 2) inadequate model/presentation separation, a deeper and more widespread problem, but not hard to tackle either.

And now that I understand what problems I'm facing, I'm calm and confident about the code again and can implement the refactorings gradually with minimal disruption.

What did I learn?

  1. Code smells are good, not to be feared. They mean I'm learning about my code, and am about to make a nice improvement in its design once I figure out the source of the smell.
  2. It's good to be bothered about the state of the code, but don't worry about the annoyance until I understand it as a clearly defined problem. Then I can take concrete action.

Something not to do

  1. Work for a long time on a document, saving fairly infrequently.
  2. Decide the document should have a different name, and instead of saving it again with that new name, move the original file to that location.
  3. Open the file at the new location, electing not to save the changes.
Hope you're having a great morning doing today's work. I'll be here repeating yesterday afternoon, which I don't recall enjoying too much.

urlencode in Ruby

I dug around for too long to find this one:

You can urlencode by calling CGI.escape.