Jake Worth

Answering Questions on Stack Overflow

Published: January 27, 2022 3 min read

I enjoy answering questions on Stack Overflow. It helps me learn and practice reviewing code. In the beginning, it also unlocked site features like voting.

I have 4,624 rep on the site today. Not much, but much more than the average user.

Maybe you’d like to answer questions too! Maybe you want to learn, or practice giving feedback. Maybe you want to contribute to the community, or collect rep and privileges on the site. If any of these are of interest, this post will explain how I answer questions on Stack Overflow.

🥞 As a working example, here’s an accepted answer of mine: ‘Converting React files to Typescript’.

Find the Question

You can’t answer the question until you know what the question is. That can be difficult.

XY problems are common on Stack Overflow. Empathetic askers want to help the people who are helping them by offering a solution. But often, they end up asking for help with their solution rather than the problem. Implementing the wrong solution isn’t progress.

It takes experience to spot these kinds of questions. They usually start with an unusual request, like: “how do I force a failing test to pass on CI?” Leave comments asking questions until you arrive at the actual question.

🥞 In my answer, the title of the question, ‘Converting React files to Typescript’, was far from the real question, ‘why is products.find not a function?’

Gather Information

Stack Overflow loves a minimal, reproducible example (reprex). In almost nine years on the site I’ve learned that questions are rarely close to this ideal. If the asker had that kind of debugging instinct, they would likely not be stuck. Requesting edits sometimes works.

I enjoy messy questions. They give me time because the needle is deeper in the haystack.

For frontend questions, I recommend Code Sandbox. Type react.new into a browser bar, and you’ll be redirected to a sandbox with a CRA React.js app ready to go. Paste the code and start whittling down to a reprex.

For languages, I use a REPL like IRB for Ruby. For server-rendered frameworks I often spin up a new app or hack on the many abandonware projects on my computer.

It’s just debugging from here. Get stuck, make assertions, test them, read docs.

🥞 In my answer, reading the code showed me that products was being passed as an object, but a function was being called on it that does not exist on JavaScript objects.

Answer Quickly

Once I get an answer, I post a hasty version. Then, I take about five minutes to add code blocks, links, and check spelling and grammar. Part of the gamification of Stack Overflow is that the first correct answer gets attention, so being first and correct is desirable.

🥞 In my answer, I iterated on my answer as a comment. Submitting the comment, seeing positive feedback from the asker, and answering a second question in the comments, told me I was on the right track.

Make Comments Obsolete

The last thing I do was described in a Meta Stack Overflow article as ‘make comments obsolete’. If your answer is good you’ll get feedback. An example would be: “why not use fetch?” When I agree with the feedback, I edit my post so the code is better. When I don’t agree, I can raise and challenge the argument. Leverage the feedback.

Conclusion

Enjoy Stack Overflow; help people and earn rep! I’m Jake Worth on the site. I’d love to hear your tips and tricks for being a good Stack Overflow citizen.

✉️ Get better at programming by learning with me. Subscribe to Jake Worth's Newsletter for bi-weekly ideas, creations, and curated resources from across the world of programming. Join me today!


Blog of Jake Worth, software engineer in Maine.

© 2022 Jake Worth.