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…

June 30th, 2009 → 3:32 pm
[...] primitive feature envy [...]