Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 157 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

So I was reading through the answers on this question and it got me thinking. I see this question and I immediately realize this is most likely being asked by a java 101 student or someone just getting started with the language, therefore I assume this code isn't going to be operating the detonation codes for a nuclear launch or anything. So when preparing an answer I tend to keep most of the structure of their already existing program and use primitive types when other more advanced types may be available, and even keep around logic errors that don't pertain to the actual question being asked.

I see some answers that completely change all of the OP's code to use more advanced data structures and functions in order to get a more efficient or correct program, but I feel this doesn't help the asker nearly as much as making the small corrections to their already existing program in order to get the result they thought they should be getting.

On one hand, I completely agree that the other answers give a much better solution to the problem at hand, but on the other hand I feel they are less likely to help the OP learn from the question since they are using more advanced concepts.

So my question is, is it bad to consider what the OP is more likely to understand when coming up with an answer, even if it is perhaps slightly more inefficient or missing a few edge cases (even if those edge cases aren't related to the actual question asked, but noticed by other parts of posted code). Or should I always try to correct bigger structural issues with the code, even if it will be difficult to explain why they should make those changes in words the OP would be able to understand, perhaps for the betterment of anyone who may look at that answer in the future?

share|improve this question
For what it's worth, reasoning like this is why [homework] was an exception to the "no meta tags" rule for a long time. – Pops Nov 21 '12 at 17:59
I agree -- bonus points for pointing out and explaining a couple of the Op's mistakes. Some do not agree: I once got down-voted for preserving in my answer the Op's use of an implicit SQL join. :P – McGarnagle Nov 21 '12 at 18:18
Somtimes it can be enough to just say that "this section and that section aren't really designed properly, but I'm leaving it since it's not germane to the question". If they're interested in "doing it right" they can comment and you can fix it; if not, you don't waste your time re-designing something they aren't going to fix. – Servy Nov 21 '12 at 18:28
up vote 7 down vote accepted

You could always provide both answers and explain the differences. It takes more time and effort than giving either answer alone, but once in a while you get rewarded with lots of upvotes.

share|improve this answer

It is very likely that future visitors to that question will have a similar amount of experience with the OP.

When answering questions of learners, It is more important the learner understands your answer, than it is for your answer to have good form.

People will learn a lot more if they understand why they experienced what they did than if you overwhelm with new concepts

share|improve this answer
Yeah I definitely had this thought as well, I figure if someone ends up looking at this question for answers they will likely have similar knowledge on the subject as the OP – KDiTraglia Nov 21 '12 at 18:01
Yet at the same time, overuse of this logic leads to lots of bad practices being propagated and spreading around among novice users because the canonical answers (which didn't start out as a canonical answer) to common questions avoided using more correct tools for a task. – Servy Nov 21 '12 at 18:26
@Servy Also a very good point, thus why I opened the question. I would think we all started with bad practices just so we could get over some of the initial hurdles of learning programming (and maybe temporarily ignoring those bad practices helped us actually be able to digest our first pieces of code), and as we got better we slowly refined them, so I still see value in the easier answer. If someone is simply going to copy the code and not strive to improve their knowledge, I think they are doomed whether the code is sloppy or pristine. – KDiTraglia Nov 21 '12 at 20:05
@KDiTraglia True, which is why I mentioned this compromise in a comment that I often take. If you just mention that a section has problems, even if you don't take the time/effort to re-write and explain your changes, it can help dissuade future readers from copying those unrelated sections. – Servy Nov 21 '12 at 20:13

I personally tend to consider the OP's knowledge if possible. I think it would be best to guide the OP to the best possible solution.

You could start by correcting only the errors in the OPs existing code. After that you can give tips about what could be enhanced to make the code more efficient.

It would be best to give a useful answer to the OP and future visitors.

share|improve this answer

You provide the answer that you feel helps the asker the best.

If that means you feel that simpler data structures help, there is certainly nothing stopping you using that instead of more complex and advanced structures. Adding explanations as to what you are doing to educate the asker is never going to hurt.

In the end, you are trying to help the asker solve a problem. If your answer was most helpful (and correct), it'll stand a greater chance of being upvoted and accepted. And that is never bad.

To give this a personal angle: I do this often enough; help a newbie to find the documentation and why things are the way they are. And this can include simplifying things a little, to aid understanding the important, larger picture first.

share|improve this answer
I would argue that tailoring it more to the OP gives a greater chance of being accepted, while being more correct would be more likely to get up votes (even if it wasn't actually as helpful to the OP). – KDiTraglia Nov 21 '12 at 18:04
@KDiTraglia: Sorry, I assumed that giving a correct answer was a given. – Martijn Pieters Nov 21 '12 at 18:06
emphasis on the word more. ie one answer solves the problem and gets the job done, but leaves inefficiencies in the OPs code for example. While another solves the problem and eliminates the inefficiencies but redesigns the original structure of the OPs code. – KDiTraglia Nov 21 '12 at 18:07
BOOM!!!!!!!!!!! – Anthony Russell Feb 2 '14 at 12:16
Boom to you too? – Martijn Pieters Feb 2 '14 at 12:23

You must log in to answer this question.

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