Started a tweet, foresaw it becoming a long flurry of tweets, decided to make a blog post.
Was spinning my wheels adding what seemed a simple feature. Most of the needed code already existed. "Just" needed a little more.
Finally figured out it was about going from two possible states to three.
Had been switching states implicitly. The code needed to be more explicit.
Took some messing around before that dawned on me, and a bit more to decide how to represent the state transitions.
Decided on names for the states. Refactored, edited comments. Not much increase in lines of code, but quite a bit of change.
I might change one of the state names to "default". Paradoxically, less descriptive yet easier to associate with what it does.
Why didn't I solve this earlier? Specs too vague? I think I could have spec'ed it to death and still missed the forest for the trees.
Maybe I just needed sleep? I spin my wheels a lot when trying to solve problems on too little sleep.
For me, in this case, it took a combination of stepping-back-and-pondering and messing-with-the-code.
Sometimes I'm slow to realize I'm spinning my wheels until I've been doing so for a while.
It helps to play Look For the Pattern. Not necessarily "pattern" as in Gang of Four, just some overarching concept.
When I've worked on teams, co-workers have often been helpful in catching my bad ideas or pointing out the forests and/or trees.
Sometimes I have to make myself open up to those conversations. At heart I am very much a solo developer.
Although I do write all code as if for public consumption.