Can one ask questions about homework here on Stack Overflow? If so, how should I go about doing so?
What guidelines should users follow when responding to homework questions?
Can one ask questions about homework here on Stack Overflow? If so, how should I go about doing so?
What guidelines should users follow when responding to homework questions?
The community has mixed feelings about homework questions. While some feel that students should be able to get an answer to any question they want to ask, others feel that Stack Overflow is not a place for homework questions at all.
This is an attempt to reconcile these two extreme positions in a way that is acceptable to the majority of the community. Note that this post is not the official position of the Stack Overflow administrators, but rather a community-edited effort to provide clear guidelines on how to respond to homework. Individual community members should, of course, use their own judgment.
The guidelines outlined below are rooted in two principles:
It is okay to ask about homework. For one, it would be impossible to stop it all, even if we wanted to. Stack Overflow exists to help programmers learn and provide a standard repository for programming problems, both simple and complex, and this includes helping students.
Providing an answer that doesn't help a student learn is not in the student's own best interest. Therefore, you might choose to treat homework questions differently than other questions.
Make a good faith attempt to solve the problem yourself first. Users here respond negatively if your question gives them the impression that you're asking them to do your work for you. On the other hand, questions that ask about a specific issue that you're having a problem with usually receive a much better response.
Ask about specific problems with your existing implementation. If you can't do that yet, try some more of your own work first or searching for more general help; your professor is likely to be a better resource at this stage than Stack Overflow.
Search for already-existing questions about your issue. Try using both the Stack Overflow site search and your favorite search engine. Most search engines allow you to limit results to a single site. For example, you can search Stack Overflow on Google. Definitely try searching for your title and/or the keywords in your title, along with the language tag for the language your question is working with. Look through at least the first several results. People tend to respond negatively if they can easily find a duplicate to your question, particularly if they can do so by just searching for your question's title...
Help us understand your baseline. Broad pleas for help like "I have no idea where to start" are problematic, because we can't know your starting level. If you are new to programming, or the specific programming language or system platform you are trying to use, and can't even write or run a simple "Hello world" program, concentrate on solving that in isolation, and return to your actual assignment only when you have solved that. Past that point, it might help to explain the purpose of the course or mention topics you have been taught recently. Do you know how to assign a value to a variable? Do you know how to loop over a range of numbers? Tell us what you already know, and tell us what you already searched for or looked at, and why those resources were not helpful for you.
Be aware of school policy. If your school has a policy regarding outside help on homework, make sure you are aware of it before you ask for/receive help on Stack Overflow. If there are specific restrictions (for example, you can receive help, but not full code samples), include them in the question so that those providing assistance can keep you out of trouble. Note that vandalism and/or edits to questions that invalidate existing answers are against policy. Attempts to hide your question after you've received an answer will not be successful and will make it harder for you to get answers to future questions. See also: I've rethought my question about a homework assignment—why can't I get it deleted?
Never use code you don't understand. It definitely won't help you later (after school, in later assignments, on tests, etc.), and it could be, at best, very embarrassing if you are asked to explain the code you turned in.
Understand the difference between "asking a question about your homework" and "asking a specific question about the code in your homework". You should never ask a question about your homework, because more often than not, it will not meet the recommendations in the rest of these guidelines. Instead, ask about the code you wrote to solve your homework problem and be specific with the inputs, desired outputs, and error messages. It is ideal if you take your code and create a minimal, reproducible example instead of pasting your entire code, especially if it is a long code block.
Try to provide an explanation that will lead the asker in the correct direction. Genuine understanding is the real goal for students, but trying to provide that is usually appreciated for any question.
Focus on the explanation rather than providing full source code. A student is more likely to learn from clear steps and proper explanation rather than ready-made code. However, if a code example will help understand the solution, don't stop yourself from providing one.
Recognize that homework is likely to include artificial constraints, and honor those constraints. Also, be aware that these constraints may affect whether a question should be closed as a duplicate. That said, there is nothing wrong with also including information in your answer about how the problem would normally be solved in the real world. It's helpful for students to learn real-world patterns, and this also makes your answer more useful to future readers.
"Lack of effort" is not a reason to close questions. If a homework question shows no good faith effort, you may cast a downvote and refrain from answering, but this is not—in itself—a close reason. (Obviously, if the question does not ask a question, is unclear, does not provide sufficient information to allow it to be answered, and/or answering it would require writing an entire book, then it should still be closed for the appropriate reason.)
Failure to comply with these guidelines is not a reason to downvote an answer. Naturally, if the answer is incorrect, low quality, poorly explained, and/or something that you would downvote anyway, then it is fine to do so. Remember that it's not always obvious at first glance that a question is homework, especially when you're not expecting to see it here. You can, according to your judgment, leave comments on the answer with suggestions on how to improve it.
Don't ridicule a student because they haven't yet learned something obvious or developed the good habits you'd expect from a seasoned programmer. Do add a respectful comment or answer that points them towards best practices and better style.
It's okay to ask if a question is homework if it would help you write a better answer, but always be polite.
FWIW, I teach a programming class, and have the following policy:
Programming is a "team sport," and it is good for you to talk with each other about ideas on how to confront the problems, and look to the Internet and other sources for ideas.
Nevertheless, the work you hand in with your name on it should represent work that you did.
If you work with others to complete your lab, list those people with your source code. Also, if you get code from an online resource, list the URL with the lab, and credit where you got the code from. This is a common courtesy and a legal requirement, even for free, open-source software.
Failure to give credit is plagiarism. Work that is apparent plagiarism may receive little or no credit.
user contributions licensed under cc-wiki with attribution required
. If you take something non-trivial from here and use it verbatim in your own work (whether as a student or otherwise) without attributing it correctly to the author and to SE then you would be in breach of that licence, would you not?
summary:
When answering (if you choose to), make sure you include plenty of explanation in English, not just code. But don't hold back from going into interesting details or showing code just because of who asked the question for what reason. The point of SO is to answer questions for future readers, not just for the OP.
When voting, be generous to new users if they aren't specifically asking SO to do their homework for them. But when you find old bad questions (homework or not) definitely downvote them. So there's kind of a "grace period" for sort-of-ok homework questions that don't have much future value, in case people want to spend their time helping that one person.
One of SO's important goals is to be a repository of useful answers to useful questions.
Homework questions sometimes subvert that, especially debugging questions which often have little to no future value and just clutter up everyone's search results. When you're looking for a good way to do something, you don't want to find all the confused bad ways, and answers debugging them but still implementing the bad way. Keep that in mind when answering (or choosing not to answer) a homework question.
If there's anything interesting worth saying in answer to a question (including a nice way to code something), I'm going to put that in an answer. To be an answer to the question asked, you do also have to directly answer the question (including pointing out things wrong with the OP's implementation, or explaining exactly why their code behaves the way it does).
I do tend to include more conceptual explanation than I would otherwise when answering a homework question, because usually it's clear that missing concepts are the reason they needed to ask in the first place instead of just writing some code.
But if the OP didn't want a complete answer to their question, they shouldn't have asked on SO. If I think it's worth answering in the first place, I don't like leaving out details or suggestions that would be useful to future readers wondering about the same problem.
If you just want guidance (or you don't know where to start), ask your instructor or TA for help.
I'm not saying you must always include working code when answering. Explain in English what's wrong with the OP's code, and/or what they should be doing. Don't reward lazy questions (homework or not) with code dumps. But don't hold back from showing code only because the original asker of the question was doing a homework problem.
If there's an alternate much better way to do what the OP was attempting, I'd encourage mentioning it. Sometimes that's easiest and clearest with code.
Homework questions are often posted by new users that don't know how to ask good questions yet. They're also often asking about the same thing that's been asked a zillion times, but with a unique misunderstanding or bug in their code.
I usually resist downvoting new questions like that, even though they have near-zero future value, as long as they include a [mcve]
(if it's a debugging question). I will go looking for a duplicate to close it if possible, though (with an answer that explains things in English, not just a code dump, of course.)
But when I come across old questions like that (near-zero future value, with a problem that could have been found easily with a debugger), I downvote ruthlessly. I have no patience for old bad questions wasting my time in search results if they won't ever make good duplicate targets because they have two or three misunderstandings combined with various bugs.
For example, there are a zillion questions about printing or reading integers in x86 assembly language (usually 16-bit DOS because some schools are still teaching that??), and most of them are conceptual (multi-digit integers can't be handled as easily as single-digit ASCII) combined with debugging questions, so they aren't all duplicates.
(Using a debugger is more important in assembly language than in higher-level languages, because many totally wrong things are not build-time errors or warnings. Watching register values change as you single-step would reveal the bug in more than half the asm-homework questions that get asked.)
[Open letter to students with homework problems](https://softwareengineering.meta.stackexchange.com/q/6166)
[How do I ask and answer homework questions?](https://meta.stackoverflow.com/q/334822)
(Please do not delete this comment again!)