How 'Being Stuck' Can Make Us Smarter

06 Sep 2023

What is the best thing to do when you get stuck on a line of code? It is wise to trace back our thoughts, but sometimes we really can benefit from another set of eyes. One thing I suggest doing the next time this happens is opening a tab to Stack Overflow. This long-known gem is a community-based public platform to find and contribute answers to coding questions. According to their site, there are over 100+ million monthly visitors. The forum is a crucial tool for professional, passionate, and enthusiast programmers alike.

For the vast community of Stack Overflow users, time is a scarce and expensive resource. Especially for back-to-back projects or homework, many of us can’t afford to spend extensive, unnecessary hours writing or debugging code. All we want is for our code to run correctly and perform as intended. Vice versa, an expert would not feel inclined to provide you with the best answer, if they don’t find an intellectual benefit for them. This is where asking smart questions is an extremely valuable tool when using Stack Overflow and forums like it. Stack Overflow is a tool that can only help if you know how to use it.

What is a Smart Question?

A Smart Question is one that can be asked and answered well. In How to ask questions the smart way, Eric Raymond gives straightforward yet informative guidelines on what to do before and after asking questions. It humbles you into a position to effectively interact with the open source community online. Some of his key points include first making sure your question is unasked by others, being precise and informative about your problem, being explicit with your goal in mind, and showing common courtesy.

One of the best ways to understand concepts, for me at least, is through examples. Here are two that can at least convince us of this “smart” way and allow us reflect on our style.

A Not So Smart Question

I want to use "onclick" event in a JavaScript class but it doesn't working

it seems to not assign "onclick" event function

it works with jQuery but not with vanilla JavaScript

I instantiate a object of class in other JavaScript files

please help me

This question is closed on Stack Overflow, for simply not being smart. In this question from Stack Overflow, the user had trouble getting “onclick” to work in JavaScript. I chose this question to highlight its lack of readability and proper grammar. The users’ stylistic choices would make a reader less likely to continue reading it. Its heading, “adding onclick event in javascript class not working”, may potentially offend developers or experts of JavaScript, a widely-used programming language. It is one notion to acknowledge being stuck, but it is another to say the whole program does not work overall.

This question does not pinpoint a specific problem they need help with. They state the issue that “it seems to not assign “onclick” event function, and they “instantiate a object of class in other JavaScript files”, but the exact files are not given. Only a snippet of code is provided, which makes it difficult to identify the source of problems. As a result, answers to this question are at most one sentence long. That isn’t very helpful. To help others help you, it is best practice to include the shortest while necessary code.

A Smarter Question

How do I return the response/result from a function foo that makes an asynchronous request?

I am trying to return the value from the callback, as well as assigning the result to a local variable inside the function and returning that one, but none of those ways actually return the response — they all return undefined or whatever the initial value of the variable result is.

In this question from Stack Overflow, the user wanted to return the response from an asynchronous call in JavaScript. It has a clear, specific action that other people would feel gravitated towards. They provide not just the question within the scope of their function, but their ideas behind implementation as well to check out, using Node.js and a Promise block—important topics of JavaScript. It sparked interest in the community, resulting in even more detailed solutions. With over 2 million views, this topic must be commonly asked and extremely useful. There was no singular answer, which made the discussion very nuanced.

Smarter Programming

comic

Stack Overflow is a highly resourceful and reputable tool. Sometimes we can find ourselves being overly dependent on it to help us code. If you were already familiar with Stack Overflow, you’re guilty of having too many tabs of questions open at once. At some points it became overwhelming to try to take it all in.

Personally another factor into using forums while coding, is trusting my intuition. That is how we connect the external online solutions to our projects.

As a programmer, especially as a Computer Science student currently taking a Software Engineering Class, I admit I may not be fully technically competent yet. However, one thing we all have is the ability to demonstrate an open-minded, thoughtful, and observant attitude as we learn. As we start to question effectively, we re-train our brain to think more effectively. In turn, we will get to answer other questions. Who knows, we may even find the answer ourselves just by knowing how to ask it in a smart way.