114

Looking at this question got me thinking. A lot of people post homework question / programming assignments on Stack Overflow and that's fine if they make a legitimate effort (the linked question, not so much) and need help. But my concern is that a lot of homework questions are deliberately contrived with some silly restriction that doesn't make sense for a real programming question but, probably, makes sense in the context of the course and addresses the specific thing the instructor is trying to teach.

For example, in the question linked the user wants to determine the number of days in a month. Anybody who has spent more than 5 minutes in the .NET framework would (should) immediately go to DateTime.DaysInMonth and get the answer in one line. But the user's question explicitly states that they must use a switch statement. It should be obvious to anybody with experience that this is the wrong way to do it because leap years are tricky (a fact recognized by the question with the statement that they should just always return 28 days for February) and it's pretty much always a bad idea to roll your own code for handling dates and times.

The problem is if somebody legitimately searching for how to get the number of days from a month comes across this question and thinks that having a switch statement is the only way to do it, they will be mislead. Now this particular question probably isn't a problem, it's been voted down and closed anyway, but there are probably other questions out there with unnecessary restrictions placed on the solution (essentially XY problems) and it seems they ought to be recognized as such so somebody else searching for a solution doesn't end up thinking that the restriction placed on the homework question is actually a real thing.

So, on the one hand, I think we should help people with homework questions if they've made a real effort to solve it and are stuck, regardless of whatever restrictions their instructor has put on it. But on the other hand, I wonder if the answers are really useful to the broader audience of Stack Overflow users who are trying to solve the same (or similar) problem but don't have one hand tied behind their back?

So somebody rightly answered the question with the correct way to get the number of days in the month without regard to the restriction of using a switch statement. However, their answer still picked up a downvote, unjustly in my opinion, but I can also understand why somebody might look at an answer that has ignored the restriction and downvote it because they haven't actually answered the question. So ignoring the restriction and giving a better solution to the original problem does risk picking up downvotes.

I guess perhaps the solution is to give the better solution (preferably first) and then give an answer including the restriction. But it still seems like the question is less than useful to anybody that isn't doing the exact same class with the exact same instructor.

32
  • 63
    If people come across this and blindly use the solution without reading everything properly, that's their loss and there is nothing we can do about it. In your example pretty much every response has been "don't use a switch, use the built in method", I imagine the same applies to all of these kind of questions
    – Joe
    Commented Jul 28, 2014 at 13:58
  • 11
    You have sufficient rights to vote to delete that question. Feel free to use it. Commented Jul 28, 2014 at 15:05
  • 10
    Yes. And he's already got his answer, copy/pasted it into his homework assignment, turned it in pretending it was his work so fairness is only something that he and his teacher need to work out. Commented Jul 28, 2014 at 15:49
  • 23
    Keep in mind that sometimes contrived questions show up in real life too. "I can't use proper encryption because the hardware I interact with doesn't support SSL." "I can't use Joda-Time because my boss is convinced it will bring about the apocalypse." "I can't use library X because legal is convinced Y." "Our coding standards say no regex ever because reasons." etc etc
    – thegrinner
    Commented Jul 28, 2014 at 18:39
  • 5
    @thegrinner: For sure, but I could also argue, depending on the level of pure arbitrariness of the restriction, that a lot of those question aren't terribly useful to anybody else either. But there is definitely a level of arbitrary restriction that comes up with homework questions, such as "use a switch statement" which are a level above those real-life restrictions. Commented Jul 28, 2014 at 18:54
  • 7
    I suggest a new close reason: "Seems like a homework assignment". Commented Jul 28, 2014 at 19:03
  • 6
    Why not have a homework tag?
    – Autonomous
    Commented Jul 28, 2014 at 19:03
  • 8
    @ParagS.Chandakkar: Because the homework tag was already burned. I doubt anybody wants to resurrect it. Commented Jul 28, 2014 at 19:04
  • 4
    @FrankN.Stein: I don't think being homework is a reason to close. It's not about it being homework, but rather about being restricted in some arbitrary way that makes the answer pretty much useless for anybody else. A homework question without some silly restriction would be just fine. A homework question could even have some sensible restrictions that seem more like real-life restrictions and be okay for SO. Commented Jul 28, 2014 at 19:06
  • 3
    Because other SE sites are allowed to make their own rules; it was an awe inspiring (in the old school causing terror sense) sewer of crap questions on SO despite years of people trying to nuke the influx of new trash questions as they were posted. When we decided to clean it out 2 years ago one of the results was that Marshal badges were handed out like candy on the 4th of July because it was possible to sort the tag by vote and flag 80 or 90% of the negative score questions for destruction. Commented Jul 28, 2014 at 20:00
  • 10
    A question with an unrealistic arbitrary restriction is arguably too localised, which used to be an allowed close reason.
    – Raedwald
    Commented Jul 28, 2014 at 20:35
  • 6
    Anyone remembers the good 'ole "Homework" tag? It was removed some time ago. I recon it would, among other things, denote clearly that the question is likely not about the "professional" way to solve a problem but about the educating. - Voting to re-initroduce the "Homework" tag.
    – JimmyB
    Commented Jul 29, 2014 at 8:04
  • 15
    Homework.StackOverflow.com or ToLazyToDoItMyself.StackOverflow.com Commented Jul 29, 2014 at 9:59
  • 4
    Homework is irrelevant. If I have a problem that I can't solve, it doesn't matter if it was a problem given to me by my teacher, or my boss. Sure, homework tends to have ridiculous restrictions, but try working in a company which has a paranoid management who have a firm grip on how the code is produced.
    – Joe
    Commented Jul 29, 2014 at 10:31
  • 4
    AsThomas Landauer points out, these questions can be very frustrating to try and answer when the OP is unable to clearly articulate the restrictions. It's even more "fun" when they don't even mention the restrictions up front, but slowly reveal them, one by one, as the answers come rolling in. :(
    – PM 2Ring
    Commented Nov 22, 2017 at 19:39

5 Answers 5

58

It seems to me the best solution is already in your question. You say:

I guess perhaps the solution is to give the better solution (preferably first) and then give an answer including the restriction.

Excellent idea, and I will try to do that.

How else could we deal with it? We could also try to educate all new users to add a proviso that "This is homework. Answers that show how this could be addressed without the restrictions are welcome, but the accepted answer must include the restriction". But, this would be the same as the homework tag. Also, we could try to remind people to include both the restricted and unrestricted solution in their answers, but how many people on this site actually bother to read the guidelines for answering questions? All you end up doing with either of these approaches is adding to the clutter, and increasing the amount of stuff that people have to remember when writing an answer. Probably neither of these is a good (or even remotely practical) idea.

Your point about how useful the question and answer are to the wider community is still valid, though:

But it still seems like the question is less than useful to anybody that isn't doing the exact same class with the exact same instructor.

If that's right, this is covered by the "too localized" tag.

Will all this said, we also need remember that there is a reason why students are asked these kind of questions with restrictions: to help them learn. And we can all continue to learn: I know I've picked up some brass among the muck on this site. So, I suggest therefore that these questions with odd restrictions aren't all completely useless, and we just need to look at them as the learning opportunities that they are.

4
  • "We could try to educate all new users to add a proviso that..." This would probably not work because I doubt people who really want an answer will bother to add it. Maybe there could be some closure-like process where users can add a homework message to the question.
    – Anonymous
    Commented Jul 29, 2014 at 2:00
  • 1
    Right. That problem with people not reading guidance was what I was getting at. And I think a homework tag would be a) ignored and b) clutter, and c) basically irrelevant. Commented Jul 29, 2014 at 2:35
  • 3
    "We could try to educate all new users to add a proviso that 'This is homework...'" The homework tag was eliminated, and educating new users asking homework problems to write such a provision is much harder than tagging it homework was. If the restriction isn't made obvious enough in the question, people can edit (or suggest an edit) to call it out more. Commented Jul 29, 2014 at 7:26
  • 2
    I tend to go with "Answer the question they've asked, and then explain why they should do it another way, if possible"
    – Jon Story
    Commented Oct 14, 2014 at 16:00
20

a lot of homework questions are deliberately contrived with some silly restriction that doesn't make sense for a real programming question

Seen through the lens of someone who thinks the technology or library you are using is terrible, then the majority of questions asking how to use specific technologies have a silly restriction.

(Should people be editing PHP questions and say "You shouldn't be using PHP...the right way to do this is to use Haskell..."?)

There's space to write as many answers as people want to provide: ignoring the constraint and telling you not to do it that way, embracing the constraint wantonly, or giving a balanced opinion of both. It's the job of the person finding the question to look through the answers. Voting, commenting, and editing are there to fill in the details...perhaps weird constraints should be bolded or called out obviously.

If someone is just copying and pasting the first thing they find, there's not a lot that can be done anyway.

2
  • “(Should people be editing PHP questions and say "You shouldn't be using PHP...the right way to do this is to use Haskell..."?)” No, because this is not what edits are for, but you are changing the subject. We were discussing contrived homework questions. Commented Jul 31, 2014 at 6:50
  • 5
    @PascalCuoq The point is that many questions that aren't homework have constraints that you could well think of as silly. Every set of answers walks the line between suggesting alternative models vs. fully accepting "the questioner's reality". It's already been established that there is no "homework" tag and a question needs to be framed to stand on its own. And arbitrary constraints are fine--even if someone is just curious and has no assignment or practical reason for asking--they might just want to know. So this discussion should be about arbitrary constraints wherever they come from. Commented Jul 31, 2014 at 7:55
7

Some restrictions do make sense in a pedagogical setting. In the case at hand, it looks like using .NET is just accidental; they are learning the very basics of programming in a way that should be applicable without much effort to C, Python, or Java. That is, in almost any language you can create a switch (or equivalent), but very few have a builtin to get the number of days of the month.

1
  • 6
    Right. Without the restriction "you may not use a library/standard function here", it would be impossible to teach fairly low-level topics. The more accomodating a language is, the more teachers have to forbid. Example: calculating the value of pi.
    – Jongware
    Commented Jul 29, 2014 at 12:44
3

A question with arbitrary unrealistic restrictions will not be useful to anyone else. According to the question down-vote tool tip that is a reason to down-vote the question.

This is meant to be site for "professional and enthusiast programmers". Would a professional or enthusiast ever post such a question? If not, the question must be off topic, and the only uncertainty would be which close reason to use.

A professional would never ask such a question. They do not have contrived homework problems to solve; they have practical problems to solve.They might ask a how to do something without using functionality provided by a new version of the standard library, because it is not yet practical for them to upgrade. But that is not at all like a contrived homework question.

An enthusiast might want to code some functionality with a self-imposed restriction, as a personal challenge or to deepen their understanding. But they would make considerable effort themselves; they would post a debugging question, and the code would not be riddled with errors, questionable constructs and poor style.

So questions about how to do something with contrived restrictions can be on topic. Except the on topic cases look nothing like a typical homework question of this form. The specifics of the question are different; the work done by the poster is more extensive and better; the contrived restrictions are not wholly impractical. So no, I do not think these kinds of homework question are on topic.

4
  • 4
    Unless of course that person is facing the same restrictions... Plus your arbitrary unrealistic restriction might be someone else's environment; who defines "arbitrary" and "unrealistic" and what if I disagree
    – Ben
    Commented Jul 28, 2014 at 23:14
  • 6
    @Ben the voter decides whether the constraints are arbitrary and unrealistic, just like all other decisions about up voting and downvoting. Up voting and down voting is not like flagging or vote-to-close, for which there is guidance and practice on what is right or wrong.
    – Raedwald
    Commented Jul 28, 2014 at 23:20
  • 1
    There is guidance for upvoting and downvoting. Hover your mouse over the buttons to see the tooltip help. I agree with Ben. This whole question assumes one person's view of what is reasonable, and that the only questions posed on SO should be to help programmers solve "legitimate" problems in the "real world", in the "right way". But, based on my survey of what goes on here, a lot of it is about people learning. Just learning. And we very often pose arbitrary restrictions, to learn new ways of doing things, and otherwise expand our minds. Commented Jul 29, 2014 at 2:20
  • There's also the point of teaching LOGIC over LIBRARIES. eg if I'm a lecturer and I'm trying to teach about switches and dates, I want the student to understand how to use switches to calculate dates... I don't want them to just think "oh, there's a java library for that" because, one day, they won't be using Java.
    – Jon Story
    Commented Oct 14, 2014 at 16:14
-25

I suggest a new close reason, "Contains an arbitrary restriction". That would have two benefits:

  1. Reduce the clutter of bad ways of doing things on SO.
  2. Help teachers of programming who need to construct exercises for their students.

Really smart students will do the exercise themselves, regardless of whether SO contains an answer. The problem is not so smart students who would rather ask than develop their own skills. This close reason would give teachers an easy way of constructing questions that will not get into the SO database, without limiting any class of real questions.

If there is a non-pedagogical reason for a restriction, it can and should be explained in the question: "I cannot use library X because ...".

13
  • 2
    I'm leaning towards agreeing that they'd best be closed. Of course, such a reason would also end up being used for questions like "how do I do X without using JQuery". Which isn't quite the same category (I think). But it might prompt them to explain more clearly why they couldn't use it. Commented Jul 28, 2014 at 15:59
  • 8
    This is a bad question, but not because it contains some seemingly arbitrary restrictions, and it's certainly possible for a question to contain restrictions that you feel are arbitrary that can make entirely fine questions. There is no reason at all for this close reason to exist.
    – Servy
    Commented Jul 28, 2014 at 16:00
  • 22
    Completely disagree. Arbitrary restrictions exist in the real world and in the academic world. Learning to program is a difficult thing to do, and refusing to help when there's an arbitrary restriction will do a net disservice to the community. Instead, we should try to give them hints at how to proceed without just giving them the entire answer.
    – mason
    Commented Jul 28, 2014 at 16:29
  • 2
    I'd change your close reason to "Seems like a homework"... ;) Commented Jul 28, 2014 at 16:32
  • agree with @Servy, there are often business reasons for restrictions to be imposed that may be seen as limiting to others. Commented Jul 28, 2014 at 16:38
  • 3
    @user3791372: I think there is a difference between business reasons like "you can't use 3rd party libraries because the PHB thinks they are dangerous" and "you must use a switch statement here". I think there is a class of arbitrary restriction that is just out and out arbitrary, but the problem is identifying those cases and that might well make the proposed close reason unworkable. Commented Jul 28, 2014 at 16:51
  • 2
    +1 I couldn’t agree more. The “too localised” close reason did this well in the past. These days I just use “too broad” instead, since there isn’t really a better option.
    – user1804599
    Commented Jul 28, 2014 at 18:41
  • @matt We must use the [insert arbitrary commercial 3rd party tool have]. We have paid [insert arbitrary large sum here] for it and PHB wouldn't like to hear we have wasted money on something we didn't need. Commented Jul 28, 2014 at 19:05
  • @JanDvorak: Two things; first, it's arguable whether that question would be useful or relevant to other people (depending on the obscurity of the 3rd party tool and it's appropriateness for the problem at hand) and second, I feel the level of arbitrariness I'm referring to would be more like "We must use [insert very specific function in arbitrary commercial 3rd party tool]" which, I think, falls into the category of XY problems Commented Jul 28, 2014 at 19:24
  • @MattBurland I think these questions are typical of an XY problem, but perhaps in a non-obvious way. The real problem is that the student does not yet know how to program, and the solution is to practice programming, including doing exercises with arbitrary limitations. Commented Jul 28, 2014 at 20:02
  • @PatriciaShanahan: I'm not suggesting that these question might not be useful exercises for somebody learning programming (although it would be nice to have the instructor come up with a less brain-dead example of using a switch statement). The question is whether they are useful questions to have on SO? and if the limitations aren't likely in real-life should they be removed or otherwise marked to avoid anybody mistaking a good answer to a question with a restriction as being the right answer to the non-restricted question? Commented Jul 28, 2014 at 20:08
  • 1
    @PatriciaShanahan That's true if the SO question is <dump of assignment's requirements> how do I do this? If they have a specific problem that is well defined that they came across while implementing their assignment, even if it has seemingly arbitrary restrictions, then that wouldn't apply.
    – Servy
    Commented Jul 28, 2014 at 21:03
  • 2
    The close reason could be something like "Too specific arbitrary restrictions to be a useful question for others." Commented Jul 29, 2014 at 10:03

You must log in to answer this question.

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