an apparent case of specific anosmia

A couple of weeks ago I discovered I had missed dozens of smells in a piece of code I thought I knew well. And today I discovered yet another smell in the same code, this time a really big one. What’s wrong with me?

I have a bunch of code, code that I wrote a while back. I revisited it a couple of weeks ago, because there was a smell in the the back of my mind and I wanted to scratch it. (Equating problems in code with bad smells has always struck me as an awkward metaphor, and somehow I can sense this post being more awkward than most.) However, the remedy for the smell that had been gnawing at me was large and complex, so before tackling it I thought I would look for anything simpler to tackle first. Low-hanging fruit to get my coding muscles warmed up. I put on my code reviewer’s hat and within a few minutes I had found around a dozen other smells. As is my wont, I marked them in the code with <SMELL> comments, and pretty soon there were long sections of the code with a comment on every line!

I had begun this exercise feeling fairly confident that the smell I knew about was pretty much the only smell in the code. But I came away wondering why I had missed all those others. One person, one set of knowledge about smells; two different hats, two very different perceptions of the code. Why?

I now believe this is a case, not of specific anosmia (the inability to detect certain smells, aka “smell blindness”), but of not listening to the code. I had one specific refactoring in mind, and my entire view of the code was distorted by the lens of that goal. But the code wanted something different; and many of these newly-discovered smells were clearly more serious and more urgent than mine. Note to self: let the code set the direction.

And so I thought that was that. I had a list of smells to tackle, and I sat down today to pick one and fix it. But as I was reading through, looking for a candidate, yet another smell hit me square between the eyes. This one wasn’t in the comments, because I hadn’t seen it during my review. And yet it was everywhere (I reckon 10-15% of the code is infected). What’s going on? Again, it can’t be anosmia, because I did detect it – albeit third time around. And I don’t believe this time I was blinded by any preconceived ideas, because I really had no idea what I would be tackling today.

So it must be some kind of layering effect: different smells are visible at different mental distances from the code. Today I was more distant, more detached, than on either previous occasion, and so perhaps I saw more. Maybe by placing the smell comments in the code, and out of my head, I had gained some detachment. Perhaps in doing that I had freed my mind from some of its preconceptions; and the two week break had then allowed it to see even more. When I had the goal smell in my mind it seemed like knowledge, but when I was able to devolve to the code itself, only then did the true situation become apparent.

I believe the moral of this story is that I’m a better programmer when I have Beginner’s Mind.

And here is the same post, with all those metaphors highlighted. (Let me know if I missed any?)

A couple of weeks ago I discovered I had missed dozens of smells in a piece of code I thought I knew well. And today I discovered yet another smell in the same code, this time a really big one. What’s wrong with me?

I have a bunch of code, code that I wrote a while back. I revisited it a couple of weeks ago, because there was a smell in the the back of my mind and I wanted to scratch it. (Equating problems in code with bad smells has always struck me as an awkward metaphor, and somehow I can sense this post being more awkward than most.) However, the remedy for the smell that had been gnawing at me was large and complex, so before tackling it I thought I would look for anything simpler to tackle first. Low-hanging fruit to get my coding muscles warmed up. I put on my code reviewer’s hat and within a few minutes I had found around a dozen other smells. As is my wont, I marked them in the code with <SMELL> comments, and pretty soon there were long sections of the code with a comment on every line!

I had begun this exercise feeling fairly confident that the smell I knew about was pretty much the only smell in the code. But I came away wondering why I had missed all those others. One person, one set of knowledge about smells; two different hats, two very different perceptions of the code. Why?

I now believe this is a case, not of specific anosmia (the inability to detect certain smells, aka “smell blindness“), but of not listening to the code. I had one specific refactoring in mind, and my entire view of the code was distorted by the lens of that goal. But the code wanted something different; and many of these newly-discovered smells were clearly more serious and more urgent than mine. Note to self: let the code set the direction.

And so I thought that was that. I had a list of smells to tackle, and I sat down today to pick one and fix it. But as I was reading through, looking for a candidate, yet another smell hit me square between the eyes. This one wasn’t in the comments, because I hadn’t seen it during my review. And yet it was everywhere (I reckon 10-15% of the code is infected). What’s going on? Again, it can’t be anosmia, because I did detect it – albeit third time around. And I don’t believe this time I was blinded by any preconceived ideas, because I really had no idea what I would be tackling today.

So it must be some kind of layering effect: different smells are visible at different mental distances from the code. Today I was more distant, more detached, than on either previous occasion, and so perhaps I saw more. Maybe by placing the smell comments in the code, and out of my head, I had gained some detachment. Perhaps in doing that I had freed my mind from some of its preconceptions; and the two week break had then allowed it to see even more. When I had the goal smell in my mind it seemed like knowledge, but when I was able to devolve to the code itself, only then did the true situation become apparent.

Fascinating thing, the Metaphorical Mind…

Advertisements

3 thoughts on “an apparent case of specific anosmia

  1. Pingback: Notes from a Tool User

  2. Pingback: primitive obsession in ruby « silk and spinach

  3. Pingback: Carnival of Agilists for June 22/07 – In Progress | Agile Pain Relief

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