5

It is not uncommon for new posts to contain deprecated code: whilst there may well be good reasons for it in a legacy project, it's usually discouraged in new projects.

Some users no doubt end up here with such deprecated code having followed outdated tutorials, whilst others may end up following posts on SO that contain deprecated code.

How should one respond to:

  1. new questions containing deprecated code;

  2. new answers that continue with the deprecated code used in the question, even if the answer is otherwise correct; and

  3. new answers that introduce deprecated code not found in the question?


Existing questions touching on this subject include:

2 Answers 2

5

1) new questions containing deprecated code;

This is merely a subset of the vast category of questions asking for help fixing a problem in generally-lousy code. Problems can be as minor as sloppy naming and incorrect brace positioning, and as major as injection vulnerabilities and dangerous or deprecated APIs.

The long-accepted practice here has been to... Answer the question. The best way to communicate the right way to do something is to demonstrate it solving a problem. Preaching at them while they're struggling isn't going to win you any converts.

2) new answers that continue with the deprecated code used in the question, even if the answer is otherwise correct; and

3) new answers that introduce deprecated code not found in the question?

Post or up-vote a better answer, down-vote and leave comments noting the problems on the poor answers. For older answers, simply editing to update the code can be a quick and effective solution (be sure to explain WHY in the revision comment though!)

Again, demonstrate the right way to solve the problem, and explain why it's the right way. Bonus points for making the code you're fixing simpler, shorter, and easier to understand while you're at it. Littering up a question with comments stubbornly asserting that something is WRONG without offering a concrete alternative is just annoying.

0
  1. new questions containing deprecated code;

    I currently try to comment wherever I see it, whether the question is clearly part of a legacy project or not, to warn any other readers as much as to inform the asker themselves.

    However, in some cases I have felt a certain amount of community push-back owing to such feedback not necessarily being helpful in answering the actual question posed. For example, I've been advised that a new user struggling to get basic functionality working might find a deprecation warning pointing them towards an entirely new library somewhat overwhelming.

  2. new answers that continue with the deprecated code used in the question, even if the answer is otherwise correct

    I generally don't comment again, as I will have already commented on the question (as above) and don't want to appear overly pedantic; however this leaves a potentially poor answer standing alone without any warning to its readers of its pitfalls.

  3. new answers that introduce deprecated code not found in the question?

    IMV, this certainly warrants a comment and probably a downvote too.

You must log in to answer this question.

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