35

This is a more specific question about how to answer homework questions, and I have wondered this frequently. Please refer to this question as my primary example:

https://stackoverflow.com/questions/9985768/locate-and-replace-script-few-errors-i-cannot-fix

In this question, the OP wants to know how to achieve results in python using regular expression. He clearly states it's homework, copies and pastes the original question, and then pastes his code attempt. Unfortunately, his code example is entirely problematic from start to finish and shows a lack of grasping even the fundamentals.

What is the best approach to handling these types of questions? Do we make an attempt to explain every line of their example and how to fix the syntax? Do we teach them the fundamentals in addition to trying to answer their specific question?

It seems when these types of questions pop up, they will get bashed a bit on the comment list, get some down votes, and then get closed. Sometimes I have an instinct to try and help them, but on something like this linked example, I feel like the only solution is to teach them python in an answer?

10
  • 1
    @YannisRizos: Maybe. But I hate to have to see that kind of stuff. You obviously know the person is brand new to code and lost. I feel bad.
    – jdi
    Apr 3, 2012 at 1:46
  • 6
    Warning: Personal opinion (that's allowed on MSO right???) If this really is a homework assignment then they should refer to the text or their teacher for help if they are having that many problems grasping a concept. I've lived by the philosophy that anyone can lean to program, and learned the hard way that it really should have been anyone can learn to program if they put forth the necessary effort. I voted to close because anyone that reads the language docs would likely not be plagued by similar issues. They need to do their own research before coming to us.
    – M.Babcock
    Apr 3, 2012 at 3:12
  • 2
    @M.Babcock: I believe personal opinion is fine for comments :-). I definitely agree that people should do enough research before turning to stack overflow. Unfortunately in this situation I do suspect the OP had insufficient instruction.
    – jdi
    Apr 3, 2012 at 3:20
  • Fixed that for you. Apr 3, 2012 at 3:26
  • @TheEstablishment: Fixed what?
    – jdi
    Apr 3, 2012 at 3:29
  • This problem. The question in question is now closed. On a more serious note, I don't understand what you're asking here. Obviously you have to make a call whether you think the question is worth answering (if so, well then answer it, whether that means re-teaching the person all the little things step-by-step), or not worth answering (in which case, you close it). Apr 3, 2012 at 3:30
  • 1
    @TheEstablishment: I think my question is pretty clear as you can see in the answer by Li-aung Yip. What I'm looking for is the best way to handle a question like that, and to accept the answer that the community votes up as being the "standard etiquette for homework questions". If no one else offers up an answer, then obviously Li-aung has the most acceptable one.
    – jdi
    Apr 3, 2012 at 3:34
  • @YannisRizos: Downvotes are actually "less nice" than simply commenting as the OP loses points. But yes I feel the same way. It depends on the day for me, and my current level of engagement to SO. Again though, I just wanted to find the best general consensus of the SO etiquette.
    – jdi
    Apr 3, 2012 at 4:59
  • 1
    I think what @Yannis meant by "less nice" (or at least, my interpretation and opinion) is that downvotes are no less nice when you consider what's best for the community as a whole. If somebody asks a bad question, then it's entirely correct that there should be consequences to downvoting. It really doesn't take much effort to write a reasonable question, and only a little more effort to write a good question.
    – RivieraKid
    Apr 3, 2012 at 8:07
  • 1
    For what it's worth, homework questions are a grey area - I see nothing wrong with people using SO as a resource to assist with their own learning, but too many expect us to do the work for them and don't even try to do it themselves. As far as I'm concerned, they should be tagged homework, but that should not come with negative stigma. The question should stand on it's own merits, but if it's homework, it's just as important (or more) to help the OP learn as it is to give them the answer. That also makes homework questions not a good fit for a Q&A site, since the whole answer is expected.
    – RivieraKid
    Apr 3, 2012 at 8:10

2 Answers 2

75

I find myself in this situation quite frequently, as I hang out in the and tags, which contain fewer homework questions than, say, or , but the apparent inexperience is comparable to many homework questions. These are often very simple solutions, but elude the poster due to inexperience. On one or two occasions, I've been criticized in comments for, as a high-rep user, answering a question perceived as "too easy"; but I do it when there's an opportunity to be instructive...

In , such questions will often get downvoted into oblivion and closed as too localized or NARQ. However, I think that's the wrong course of action when a solid effort is apparent. In past experience as an instructor in a technical university course attended by mostly non-technical people, I found that the diversity and disparity between individuals' abilities to adapt to new topics to be enormous. We need to judge cautiously and with nuance what is or is not "effort" on the part of the OP.

In the example question Python referenced here, the OP did clearly bring some effort along, and it happens that this individual has quite a bit of learning left to do. This was not one of those one-sentence, no-code, no-direction types of questions, and the only real thing wrong with it is that the OP doesn't name a specific problem but instead asks generically "where I went wrong." Conventionally, that's an offense often worthy of Not a real question / Unclear what you're asking...

But hold onto your closevotes and downvotes for a second!!

Often, a poster who is only just beginning to learn to write code in a particular language is also only just beginning to be introduced to programming concepts, with which come the vocabulary to be able to ask a directed question. One thing starkly missing from my own first programming courses was any instruction whatsoever on how to begin debugging a program or read error output from the compiler (1). Basically, we all just made tiny iterative changes until our C++ assignment programs compiled, then hoped the output was correct when they did compile. This seems to be the stage this poster is at, and I find no fault there.

But you asked about answering, not voting...

I happen to believe pretty strongly that an upvote-worthy answer is one which both provides a solution, and a thorough explanation of what is going on in the supplied code. It doesn't end here though; we can extend our responsibilities as answerers outside the question as asked (and yes, I remember that this particular one had no real specifics), to offer one or two extra professional freebie pointers that will hopefully slosh around the OP's brain when the next assignment (or project) begins.

When there's a specific problem you can address in an answer, address it. Provide the code needed to solve the problem, and tell the asker how your version differs from theirs and why theirs didn't work. Link to the API where appropriate (remember, the poster may not even be aware that official online API docs exist, not for lack of effort, but lack of instruction). If there is an algorithm improvement you can suggest which is outside the scope of the original question, take the time to suggest it anyway in hope that the poster may absorb a bit of your professional experience. If I see it, I'll upvote you for sure!

You don't have to rewrite the entire thing and stick it out to the very end with the poster, but if you can supply the 2 or 3 bits of information needed to progress to the next step, you can then encourage the OP to come back and ask another question, this time with more specifics. It isn't practical to teach fundamentals, but it is practical and instructive to point the users to information they can use, as in "By the way, I recommend you read the examples on file handling in the official Python documentation(link)."

I remember that in one of the 2011 podcasts, Jeff Atwood referred to Stack Overflow as "an institution of higher learning." That really stuck with me, but I realize not everyone's mission here aligns with that sentiment.

1 Anecdotally, the two coworkers I polled this morning had similar experiences in their educations.

10
  • 7
    This is a fantastic answer thats is extremely detailed. It also is aligned with my own motivated feeling to help others when I can. I am the type on SO that will usually forgive and offer something, when others vote to close. Thank you for taking the time to share this. We want people like the OP in that example question to feel like SO is a place to learn, and hopefully he will make his next question more directed.
    – jdi
    Apr 3, 2012 at 4:02
  • 1
    "Stack Overflow as "an institution of higher learning." That really stuck with me, but I realize not everyone's mission here aligns with that sentiment." -- I like to think of it as such. I wish more did.
    – RubberDuck
    Apr 28, 2014 at 18:09
  • 3
    The problem with your approach of "appreciating diversity of learning" is that, 5 years later, those wonderful "not as learned but diverse" individuals who can't write a basic loop work alongside me, instantly sextupling my workload (first, I must spend 2x time training them - your "abilities to adapt to new topics" being a major factor - ... then 1x time babysitting their work... then 1x time fixing it up... then 2x time dealing with all the bugs that are inevitable unless I simply rip out their code and write my own). So your celebration turns into my (and many other people's) pain.
    – DVK
    May 11, 2014 at 17:13
  • 1
    @DVK Interesting, and what is your solution? Tell them to leave? Let them get a poor solution with no explanation from somebody, thereby encouraging them to come back to have their work assembled for them piece by piece and learning nothing along the way? Do you think that if helpful people here refused to assist them when they're new, that they would not end up in careers they're unprepared for? That's not our fault here especially when we make an effort to instruct them, it's the fault of managers who hire them. May 11, 2014 at 18:03
  • 1
    @DVK I didn't suggest above that anyone should spoon-feed answers to homework questions. I suggested that we evaluate effort levels before jumping to closevote. May 11, 2014 at 18:03
  • 3
    @MichaelBerkowski - "my" solution is one that was officially declared as the reason for SO to exist - "A site for enthusiasts and professional programmers". If you're not enough of an enthusiast to bother trying, then it's better they leave. If they're merely too new to know they need to show their trying, that's what comments are for. Anyone worth helping would learn to write a basically acceptable question after 1 failed attempt and a "please post your problem, and your code, your input, your output, your expected output and your errors" comment.
    – DVK
    May 11, 2014 at 18:08
  • @DVK I agree with all those things, but this meta question wasn't about questions without effort or without code. Those should be commented and often closed. It was about questions with effort but lacking clear direction ...and that's where judging with nuance applies. May 11, 2014 at 18:15
  • 2
    @MichaelBerkowski - OK, for some of those, I DO have a proposed solution. meta.stackoverflow.com/questions/254386/…
    – DVK
    May 11, 2014 at 18:34
  • @DVK A fine proposal, and I'm sure meta will put good efforts into working though all its cases. May 11, 2014 at 18:44
  • 1
    Totally agree with your approach and appreciate your desire to help and teach. When I ask a basic question, not only do I get the knee-jerk reactions of "Try Google" (I did) and "Have you made any effort at all?", but also "Someone with your rep should know better than to ask such a question."
    – B Seven
    Mar 15, 2016 at 0:08
25

If answers are going to be given for a question like that at all, I feel they need to be limited to hints only.

In this example, the OP needed to learn:

  1. Spelling of variable names matters. src != scr.
  2. Strings and variables are different. src != 'src'.
  3. The python idiom for opening and looping over a file (handle = open(filename,mode); for line in handle:...)
  4. How to interpret error messages. IOError: [Errno 2] No such file or directory: 'scr' means exactly what it says on the tin. "NameError: name 'string' is not defined" is possibly the most common error message you could get.

Given that the poster showed zero understanding and zero effort, it's hard to make myself care about teaching these fundamental things from the ground up - especially when my answer will only be read by one person anyway. Far better to spend my limited time answering more interesting questions.

I'll leave the egregious use of re.sub out of this - that's the lecturer's fault for suggesting the use of a DeWalt power drill where a screwdriver (str.replace()) would do.

6
  • I really like the points you made in your 1-4 list. It is very clear that what would need to be done is to break down what they need to learn and use that in the answer as generic examples, instead of giving contextual answers to his problem. But, do you really get the sense that the OP did not try at all? Thats the conflicting part for me. I felt they tried as had as they could to create python code logic. I do blame the instructor for putting them in this position.
    – jdi
    Apr 3, 2012 at 1:53
  • I will admit it could have been worse; they could have just quoted the assignment question and asked "Please help me solve this question". It's good they at least tried to write something.
    – Li-aung Yip
    Apr 3, 2012 at 2:07
  • 3
    That said, there are two parties in a classroom: the lecturer and the student. Both are responsible for the student's learning. As a student, when the lecturer fails dismally, you aren't absolved of all responsibility for your learning - it just means you have to take charge of learning for yourself! This is the culture I want to encourage.
    – Li-aung Yip
    Apr 3, 2012 at 2:10
  • 3
    I fail to see how turning up with a complete, though non-functioning code block == zero effort. It shows me a strong effort up to the OP's limits of understanding. My first programming courses included no instruction on debugging or interpreting error output. We basically iterated changes until it compiled because we were developing an understanding of the subject matter. Apr 3, 2012 at 2:52
  • @Michael: good perspective. I'll admit I might have been a bit harsh - in hindsight I should have provided hints 1-4 above without making any judgements of the OP's failure to search or read docs. A pointer towards good google keywords or the relevant docs would have been more instructive and would have put the OP on the road to looking for his own answers in future.
    – Li-aung Yip
    Apr 3, 2012 at 7:34
  • Great answer, regardless. At least 10 people agree so far.
    – jdi
    Apr 3, 2012 at 8:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .