Asking Great Coding Questions

Knowing how to ask a good question is a VERY important skill. You will have many opportunities to practice by asking great questions to your classmates, TAs, and instructors.

When interviewing for entry-level coding positions, your interviewers will not expect you to know everything about every technical topic. A lot of effort goes into training and developing junior coders. You can show your tremendous growth potential by asking insightful, thoughtful questions.

Interviewing pro tip: Asking great questions is more impressive than knowing all the answers!

When should I ask a question?

Follow the 15 minute rule: If you are stuck for more than 15 minutes on a problem with no progress, you are REQUIRED to ask a question.

Think about it: You're a highly paid software engineer paid $50/hr. If you're stuck for two hours with no progress, you've just wasted $100. If you're making no progress after 15 minutes, take some time to put together a good question (more on that below) and ask for help!

What makes a good question?

Good questions are specific

Imagine you are the lead on an engineering team and you see a question like this:

Help! My code isn't working. What do I do?

How do you answer this? You have no idea if it requires a quick, 30 second fix or a 2 hour deep-dive. Because you're busy and don't know how big of a time commitment this requires, it's likely to go ignored.

Compare to a question like this:

I'm trying to get the last character in a string using str[str.length] but get undefined. What am I doing wrong?

This is an easy fix and is likely to get an answer very quickly.

How about something like this:

I've installed Python 3.8 on my Mac using Homebrew but python3 keeps opening up version 3.6. Can anyone help me?

Python environments are notorious for growing complicated over time and this issue might take some time sort out. Because the question is specific, it can still be answered quickly.

Good questions are clear and concise

Let's take the previous question about string length and imagine it was written like this:

Oh my gosh, strings are driving me crazy! I've tried everything I can think of but nothing seems to work. Whoever invented this language must enjoy torturing poor, hapless engineers, LOL. Anyway, my problem is that I'm trying to get the last character in a string which sounds easy but nothing is ever easy in JavaScript, am I right? My idea was to find the length of the string, then use that number to get the last character, since the last character should be the equal to the total number of characters in that string. Makes logical sense but JavaScript apparently doesn't follow logic and returns undefined instead. What do you mean, undefined?? It's defined right there!

You want people to know that you've spent a lot of time trying to figure this out and you're frustrated, but also that you're a fun person. Adding some personality will make people more likely to reach out, right?

Maybe, but it's more likely to start a casual discussion about the confusing nature of JavaScript. If you're a busy tech lead, you don't have time to engage in that conversation, or to read through a whole paragraph just to find out if there's a technical question somewhere inside. Keep it clean and concise!

Good questions show the work you've put in

Let's say you've just learned about JavaScript division in class and you wonder, what happens if you try dividing a number by zero? Your instructor asks if there are any questions, so you ask:

What happens if you divide a number by zero?

Your instructor opens up a REPL and types in 10 / 0 which returns Infinity. Now you ask:

What happens if you divide a negative number by zero?

Your instructor types -10 / 0 into the REPL which returns -Infinity. Feeling clever, you ask:

What happens if you divide zero by zero?

Your instructor types 0 / 0 which returns NaN.

Here's a better approach: Open your own REPL and try it out yourself. It will be faster than asking the instructor and doesn't take up the entire class's time. When you get to something you don't understand, try Googling it or searching the official documentation. If you still don't understand, then you can ask a question:

I tried dividing a number by zero and got Infinity, which makes sense. Then, I tried dividing 0 / 0 and got NaN, which according to Google stands for "Not a Number". If NaN isn't a number then what is it?

That's a great question! It turns out NaN actually is a number, which your instructor can demonstrate by typing typeof(NaN) which returns "number". This question shows that you understand how division and dividing by zero work, but that your confusion lies in the oddly named NaN.

You may not always have time to look things up in the middle of lecture but if you notice your instructor answers your first question by typing it out, try to answer the follow-up questions yourself if possible. Don't be lazy! If you're working on an assignment, you should definitely look it up first. Let's revisit our previous question:

I'm trying to get the last character in a string using str[str.length] but get undefined. What am I doing wrong?

This is easy to Google. Type "How do I get the last character in a JavaScript string" and you'll see many pages with detailed answers to this exact question.

Say you're in a job interview and are asked if you have any questions about the company. You reply:

What does a typical work day look like for you?

This question is fine but feels generic and lazy. Here's a better question:

I've read that your company prioritizes rapid development and frequent release of new features. How do you balance this pace with maintaining a clean codebase and polished, bug-free functionality?

This shows you've done serious research and are enthusiastic about joining the company. It also shows your insights into real challenges of software development and that you are thoughtful about the tradeoffs. Don't overlook this part of the interview! Remember, asking great questions is more impressive than knowing all the answers.

What you learned