I feel like I need to scrub myself

Yes, it is a special pre-Wednesday post from your host, Mr. MoffDub, on I Built His Cage.

Increasingly, after I have to read and, worse, hold my nose and write stringy spaghetti code at work, I get a Squidward reaction:

(could you keep it down? I’m trying to be boring)

Spongebob: Are you kidding? I’ve been playing bassinet for years! (he takes one from the wall) Give me an A, buddy!

(Squidward plays a note and Spongebob begins to sing) Squidward is my best friend in the world.

(Spongebob plays an awful bassinet with high-pitched screeching each note he plays) Squidward is my best friend in the sea.

(lets go of the bow and it flies into Squidward’s painting of his head. Squidward pulls it out and snaps it in half)

Squidward… (Patrick peeks in through the window and sings)

Patrick: …likes Patrick, more than Spongebob! (shuts the door on Patrick and makes him fall)

Spongebob: And Patrick is a dirty, stinky, rotten friend-stealer! (breaks the bassinet into pieces) Umm, I can fix this. (Squidward is steaming red and throws Spongebob out) So, uhh, I’ll see you tomorrow, Squidward! Call me!

Squidward: Yech! That was disgusting! I feel like I need to scrub myself. (opens up the curtain and screams after he sees Patrick in his tub)

Patrick: Hey, buddy. I warmed it up for ya. (shows him a brush and soap)

Thus is the effect the Evans doctrine has had on me. Unreadable, unexpressive code is so repulsive to me that it is like being thrown into mud: I have to scrub myself afterwards.

This might not be so much due to procedural code being so bad as it is that object-oriented / DDD code being so…pleasing:

PhoneNumber officePhoneNumber = 
		with("Area Code", "555").
		with("Number", "876-1123").

PhoneNumberRules[] rules =
	new ValidAreaCodeRule(),
	new NotReservedNumberRule(),
	new ProperlyFormattedDomesticRule()



This is my design for phone numbers that a co-worker challenged me to design as I saw fit. I warned him that my way of design is probably too foreign and wouldn’t fit in, but he insisted. Discouragingly, I showed this code to him. And he claimed it was too complicated.

I got that same dirty, muddy feeling that I get when I have wade through getters and setters.

It wasn’t that long ago that I wrote similarly muddy code during The Project. This is why I’m led to believe that it’s not a matter of code being ugly. The right question is:

What is it about a clean, readable, de-coupled, flexible design that I find so pleasing? What is that indescribable quality that drives me to maintain a blog and side project that strive for those qualities?

The teacher of my very first CS class, which was after school three days a week in 10th grade and was obtained after students petitioned the school, was a professor from the local community college. She described the thrill of programming as the same thrill you get when you solve a math problem or equation and it all just works.

I’m not so sure I agree. Don’t get me wrong. I like math. I liked it so much, in fact, that I got a minor degree in it. But I’ve never re-visited math problems that I’ve solved just to gawk at their elegance,
or tried to solve the same problem or equation in multiple ways.

I won’t be able to answer this question. I can, though, wax about tangential influences.

  • Part of it must be due to the creational thrill that all engineers feel after they’ve created something that works. Who can blame us? It’s like playing God with bits and bytes.

    But at the same time, writing code, period, is a creational activity, regardless of its level of elegance.

  • Part of it must be due to simplicity. A clean and readable API is a pleasure to program with, and providing such an API is an exercise of service to your current fellow and future programmers.

    But at the same time, I knew during The Project that most likely, no other programmer would come after me to maintain the code I was writing (and as of an e-mail from The Company last week, this is correct). Serving others can’t be entirely it.

  • Part of it must be due to clarity, for yourself and your customer. As Ellen Ullman put it, in a world where you have to “talk all day to a machine that demands declaration”, there is a comforting satisfaction to turn this limitation against the machine and produce code that reads like an English sentence. Readable code is your trusty flashlight in Doom 3, piercing the darkness like the light of an angel guiding you to safety.

    (now that is something I definitely can’t read)

    But at the same time, the computer itself is one of the most transparent devices you can work with. It does only what you tell it, and so the consequences are crystal clear.

  • Part of it must be due to the thrill of flexibility that is likely also shared by all engineers. There is a professionalism, a sense of rarified stature, in being able to tell others that “all you’d need to do is replace this part with that part and keep chugging.” There is a hint of service, as with simplicity, but in this case, you’re serving the customer.

    But at the same time, flexibility is the bane of the software industry. Software has no physical limits. Its limits are intellectual, and this is likely the cause of more project failures than any other cause. Failing that, the other causes, like requirements creep and bad management, can be traced back to software’s softness.

Whatever they are, I can’t quite put my finger on those intractable qualities that are so pleasing. But, like a code smell, I know when I’m clean and I know when I need to scrub myself.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: