Code Smells: TOO HARD

22 May 2012

If you're attacking a problem that just isn't coming together, stop and take a step back. The feeling of "GAH WHY IS THIS SO HARD" is a preemptive code smell, alerting you that you're about to write bad code.

My most recent TOO HARD experience was with table_print, my gem that prints objects as tables. I had Law of Demeter violations all over the place, spaghetti-coding myself into a ball I knew was not going to be maintainable. If it feels hard now, it's definitely going to feel hard in six months.

I snapped out of it when I realized I didn't have any objects to represent a row or groups of rows, just hashes upon hashes to try to keep everything straight. But that insight was a fluke - I need some concrete strategies for addressing this code smell.

Next time something is TOO HARD, I'll try to see the problem from a different perspective. Some things to try: