This is an attempt to reconcile two extreme positions in a way that is acceptable to the majority of the community:
- Some feel it's irrelevant that it's homework: always just answer with complete code.
- Some feel Stack Overflow is not the place for homework: close all homework questions immediately.
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.
##Asking about homework##
Make a good faith attempt to solve the problem yourself first. If we can't see enough work on your part your question will likely be booed off the stage; it will be voted down and closed.
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.
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.
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 code you turned in.
##Answering and moderating homework questions##
Try to provide 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.
It's usually better not to provide a complete code sample if you believe it would not help the student, using your best judgment. You can use pseudo-code first, and, in the spirit of creating a programming resource, you may come back after a suitable amount of time and edit your response to include more complete code. This way, the student still has to write their own code, but a full solution can become available after the assignment has ended.
Recognize that homework is likely to include artificial constraints, and honor those constraints. Also be aware that these constraints may affect whether or not a question should be closed as a duplicate.
Don't downvote others who answer homework questions in good faith, even if they break these guidelines (unless the answer would merit downvotes even if the question weren't homework related). It's not always obvious at first glance that a question is homework, especially when you're not expecting to see it here. It is a good idea to suggest editing the response in a comment.
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.
Don't downvote a homework question that follows the guidelines and was asked in good faith.
It's okay to ask if a question is homework, but be polite.
As for non-homework questions, questions in the spirit of "plz send teh codez" might be closed as "too broad". Use your best judgment. Remember students are new programmers and often don't yet understand what is expected of them on this site. Help them to get that understanding.