0

Sometimes I feel that the question's code can be improved in several ways, however I'm not sure of where the problem is. The problem might be more obvious if the code was better written.

Is it acceptable to put the code in a new answer with a disclaimer on top Not a real answer, only some recommendations? Or should this be avoided?

In general, I feel like doing this in the situations where the code:

  • Mixes HTML, PHP and Mysql all entangled (no SoC).
  • Has some big vulnerabilities (SQL injection, md5() for passwords, etc).
  • Using some deprecated functions (mysql_*)
  • Using ifs that span several pages of height and several nested ones; KISS

Normally, when there's only a single problem from the above, I keep it a comment whether possible. However, if several of them have to be addressed or the extension of them is so big that cannot fit into a comment, is it okay to put this big comment into an answer with a disclaimer? If not, how should we deal with this type of situations?

  • I'm afraid these will be very quickly flagged as "not an answer" and deleted. Answers are reserved for just answers – Richard Tingle Mar 22 '14 at 10:10
6

Only provide an answer if it answers the question. Period.

Remember that what you describe is also done by new users who cannot leave comments yet and having two kind of situations when you flag for Not An Answer is troublesome, for those who flag and for moderators handling the flag.

If you try to help leave one or more comments.

If the question is unclear either edit, or vote to close and in the extreme cases downvote.

Opposed to have questions that exhibit one or more of the problems you describe there are for sure examples around that DO address all or some of your stated issues. I would leave a comment with a link to a good example of how the OP could improve the code and with that improve the question.

By approaching the problem along these lines both the OP and the visitors of the question will benefit.

The best the thing to do, if possible/reasonable, is to provide an actual answer to the question where you provide context to explain the multiple issues the question has and how your answer addresses those concerns.

I do realize the last option might take more time but if done correctly it could serve as a cannonical answer that you can use to link to in comments you leave on new questions with the same issues.

  • As a counter-example, I just cleaned up someone's code with the points I said in the question and that alone solved his problem... Webpage loading images from MySQL slowly. However your recommendation at the end is what I normally do answer the question AND clean up (I just cannot put any code with a SQL injection) if needed. The question was aimed more to the situations when I cannot answer properly. – Francisco Presencia Mar 22 '14 at 15:13
  • This answer is good anyway and provides points that I didn't even think of while truly answering, so I accept it. – Francisco Presencia Mar 22 '14 at 15:20
  • 1
    Not every open question needs to be answered by you :-) If you leave it open you could also leave a comment to indicate which issues needs to be addressed in the answers... – rene Mar 22 '14 at 15:22

You must log in to answer this question.

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