Keep Going

Some real talk on getting stuck and how I work through it.

Being a developer is hard. I've been writing code for 20+ years and doing so professionally for 17 and I still struggle – a lot. I get stumped all the time. Despite all of my experience getting stuck (and unstuck), I can be pretty hard on myself.

I still get caught in the trap of looking up the mountain at how far I have to go, instead of looking back at how high I've already climbed.

I compare myself to others.

I get anxious when I'm not progressing as fast as I think I should.

I get upset when I can't wrap my head around concepts that others mention nonchalantly.

I rarely see my own victories as the wins they are.

...on and on it goes. Sound familiar? Yeah? Keep reading.

A recent example

When I embarked on this journey to learn iOS development, I simply could not wrap my head around closures, completion handlers and the like. Despite being very good with HTML, CSS, and and pretty handy with PHP and JavaScript, I couldn't put the pieces together.

I'd see a method signature like this, func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> Void) {...} and my eyes would gloss over. "What the hell is @escaping? Void? WTF does that mean?"

Even though I was basically brand new to Swift, I was brutal with myself over this. Why couldn't I understand this stuff? Why was this so hard for me? These are the "basics" according to some folks, so why am I struggling so much?

I was in the middle of building my first app and having some real ugly bugs with Lock Screen widgets. I had gotten the code really close, but it was yielding really inconsistent results. Beta testers were noticing too. I was embarrassed.

When I say I had gotten the code really close, I mean I had hacked Apple's boilerplate widget extension template into something that vaguely resembled WidgetKit API usage. But this...this is how I learn. I get my hands dirty by seeing how far I can go with what I know right now.

When I get stuck, I learn.

In this case, the bugs I had were a direct result of not really understanding how WidgetKit expects you to interact with it. I was forced to sit down, read the documentation, and scour the Internet for other examples I could learn from. In doing so, I not only figured out how to fix my bugs, I also had a real "EUREKA!" moment regarding closures and completion handlers.

By focusing on something I really cared about fixing, breaking it down piece by piece, and actually reading the documentation, I accidentally figured out a concept that had been plaguing me for weeks.

The lesson? Keep going and try not to let it get you down. Sometimes learning takes a roundabout way of happening. Sometimes you need to fumble your way into understanding. That's OK. This is basically how I've learned how to do anything in this field.

Some tips for getting unstuck

When I get stuck, particularly on code, I often try to "white-knuckle" my way through the problem. This rarely works and is never pleasant. If instead, I try one (or more) of the things below, I have much better results.

  1. Take a walk – leave your phone at home
  2. Take a nap
  3. Exercise
  4. Call a friend
  5. Hug your kids, your spouse, your dog, just hug something
  6. Do something you love – play a video game, build some LEGO, listen to a record, etc.

The point is to get away from the code and busy your mind with something else. Sometimes, when I get back to my desk, the answer suddenly springs forth, seemingly out of the ether. Almost every time though, I forget about the problem for a little while, and in doing so, I relax...and stop being so hard on myself.

If after you've stepped away, you're still truly stuck, try this: break the problem down into tiny bits and ask which parts are giving you trouble. If you still can't make out which bits you're struggling with, keep breaking them down until you do. Once you know the where you're stuck, read about that thing thoroughly, search for code samples, watch YouTube videos, read the documentation, or simply ask! You'd be surprised at how many people are excited to help, including me.

If you just keep going, you'll get there.

Follow me on Mastodon, Twitter, Instagram

Subscribe to Optimistic Closures

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.