02.02.23

I’m going to start by quoting myself 12 days ago:

“I solved another [problem] by going outside on the Interislander. I had been going nowhere with a .header selector for nearly three hours when the captain announced there was a fire in the main engine. We were evacuated to the balcony. Whilst nervous about my ability to swim I realised my ID tags were the problem. We made it to Picton and I made a resolution. Take breaks.”

Well.

I didn’t try that, and it didn’t work.

A drill being used on a computer chip

JavaScript might be a whole new language but we’re steadily learning the same lesson.

This week, I’ve solved a kata (a small – sudoku sized - coding problem) by:

  • Sleeping on it
  • Breaking for a late lunch
  • Brewing a coffee
  • Having a beersy
  • Closing my laptop and opening the Replit app

It seems the longer you stare at an issue, the less likely you are to have a that eureka moment.

When I was working on Kata 2 – Manipulating Objects, I forgot exactly that, how to manipulate objects. Dev is not my first-time using an object-orientated language, or even using JavaScript. It was the afternoon after a long day and I’m one of those lucky few ”morning people”. Unfortunately, this means my productivity quickly wanes after lunch. Brute forcing syntax, everything I tried would not change Terah’s fertility status and I had only just written a blog about how to use dot notation.

I was ignoring my toolset. Unfortunately, I have not found an accurate way to diagnose whether I’m stuck because I’ve found a ’learning moment’ or if I’m ignoring my body’s limitations. The only chance I have of doing so in future, (let’s put it in a <h1> tag so it really sinks in this time) is to:

Take breaks.

A hammer with some nails, screws, and springs

if (all you have is a hammer) {(everything looks like a) => {nail}}

During Kata 5 – Builtin Methods I found myself continuously trying to force a square peg through a round hole. Sprint-3 was still so fresh and top of mind that I was using loops, conditionals, and functions where there were specific object methods built to remove this burden.

In whereAreYou, this led to a function that returned every Scooby, rather than just the first. Why was my function not passing the checks??

            
              

1. function whereAreYou(arrayOfObjects) { 2. for (i = 0; i < arrayOfObjects.length; i++) { 3. if (arrayOfObjects[i].hiding == 'Scooby') { 4. return arrayOfObjects 5. } 6. } 7. }

Frustrated I reached out for help. A fellow student gently pointed to the .find() requirement of the exercise. I had either skimmed the question or totally skipped it, jumping into the index.test instead. After researching the method, why was I trying to use a loop anyway?

            
              

1. function whereAreYou(arrayOfObjects) { 2. let result = arrayOfObjects.find(({ hiding }) => hiding === 'Scooby') 3. return result 4. }

Although, I’d still argue that finding every Scooby is more useful. After all, what’s better than one scoop of your favourite ice cream? Two scoops of your favourite ice cream.

deBuzz deezN*ts

Often times, when I'm trying to take a break from coding I can't fully relax or be present in whatever activity is supposed to be helping me recuperate from the sometimes-intense focus of solving a small coding issue. I will find my mind drifting:

"would .filter() help here? Maybe .map()? Maybe that weird RegExp thing I read about on stackoverflow?"

Whether I'm sitting at a cafe, drifting off to sleep, or cooking supper these potential solutions pick at me. With the Replit app I can quickly jot down an idea and refocus on unfocusing.

The Replit website may be useful for solving syntax issues, a missing pair of quotes or forgetting to add the word return at school, but I used the app to solve problems when I couldn't sit at my screen. I found it great for 'thinking outside of the box'. The human thumb has a limited bandwidth compared to a keyboard and a few monitors. Most of the kata's could be solved with only a few elegant lines of code and this limitation allowed me to break out of my habits of using loops and complicated if...else statements and think of smaller, more legible solutions.

I feel comfortable with all the suggested problem-solving techniques taught this week. That said, I’ve had my failings and when I hit a wall in future I’d do well to remember: Take breaks. Ask for help. Use every tool in the toolbox.

A tool set for, AND being operated by, babies

P.S. If you’re reading this and you helped me out on campus or in the discord this week…

THANK YOU!