What was a technical roadblock that you overcame this week? How did you do it?

What was a technical roadblock that you overcame this week? How did you do it?

Photo by Erik Mclean on Unsplash

I get so tunnel-focused writing on writing code and forget that it's best to walk away from your editor (and put down TikTok) to take a break, go for a walk, go play video games, or even sit in silence outdoors for some time to recalibrate. Sometimes easier said than done.

The issue I overcame was using Object-Oriented JavaScript (classes) to encapsulate related data and behavior with vanilla.js.

TL;DR

I was tasked to refactor my code to use class constructor syntax since I was grabbing all of my objects through the DOM. I also crammed all of my procedural functions, AJAX calls, node getters, and what would soon be refactored into static/class methods all on my index.js file.

At first, I did not fully understand how I should pass objects into my static methods that rendered all my strategies from my strategies array after making an AJAX call to my Rails API. Then after a long refactor process, I had a deeper appreciation for using class constructor syntax and learned more about returning promises after building my fetch request.

Synapsis:

If you are familiar with Object-Oriented Programming and JS you will know that Javascript supports the concept of classes as a syntax for creating objects. If not, to simply put it classes specify the shared properties and methods that objects produced from the class will have. For example:

code-snapshot.png

Bonus:

Also, here is a good example of why it's okay to miss out on the latest and greatest framework/library to focus on scaling an existing language that you may have started to learn or became familiar with then dropped because youtube just recommended you to learn the next hottest Web3 codebase.

Let's call it JOMO, the joy of missing out.

Now as always here are some tunes to get you going to figure out that bug, another (1:19:51) lounge mix from South Africa, #AmpianoVibes #HappyDebugging