primitive feature envy

In My Favourite Smells Chris Wheeler tells an all-too-familiar story of code in which the use of primitives (such as ints or strings) obscures the true underlying design. Then in Primitive Obsession James Shore echoes the same thought:

“Primitive Obsession is one of my favorite smells as well: it’s easy to spot, easy to fix, and yields some really great designs when thoroughly stamped on.”

Well I just thought I’d add my “me too!” to the list…

I actually view this smell as a subclass of feature envy, in the sense that a primitive obsession often becomes apparent when a section of code spends too much time manipulating a primitive. When I said recently that my approach to refactoring legacy code is based on removing feature envy, I subconsciously included fixing primitive obsession too.

I wonder how much of what I write here is based on mental models that I haven’t surfaced yet? Probably most of it…

Advertisements

One thought on “primitive feature envy

  1. Pingback: 2005 silk and spinach top ten « silk and spinach

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