-20

Is there is a way to remove outdated versions of code to be removed from this community in all the technologies like jQuery/Java/Swift/Android because it's too painful to learn or even check solutions of question being answered.

Most of them even gives compilations problem, for example in Swift NSURL is outdated, but still most of solutions shows this and compiler removes when we copy paste it.

5
  • 15
    Moral of the story: Don't copy and paste random code from the Internet. You were fortunate that it didn't work at all; if you weren't fortunate, it could've bricked your computer by now.
    – Makoto
    Commented Oct 7, 2017 at 1:07
  • 3
    "because its too painful to learn or even check solutions of question being answered." - but it's your job to learn it...? It's not our fault code on the internet provided by a volunteer stranger doesn't work in a certain version. Learn from the answer to formulate code that does work.
    – Andrew Li
    Commented Oct 7, 2017 at 2:41
  • andrew technology is not just a "Job" for me its a passion that's all i do in my life. i believe every problem has solution i have raised this problem so that somehow we can resolve it. Its not the job or duty of any volunteer. its about what exist in real world and how to solve it
    – user6457240
    Commented Oct 7, 2017 at 2:47
  • I can understand where your frustration is coming from. But this sort of a thing is quite rare. Most of the technologies are improved keeping the legacy in mind. But consider this.. Isn't it true that because of a number of practical reasons, people continue to work with older versions of a lot of technologies? Isn't it more constructive to think of this problem as the one of a version tagging or maybe a way to identify answers which have become unusable?
    – absin
    Commented Oct 7, 2017 at 9:26
  • 1
    How about you read and understand what code does before reusing it.
    – Magisch
    Commented Oct 9, 2017 at 8:12

1 Answer 1

15

Is there a way?

No. It is technically not possible. Many / most source code embedded in Answers is actually code fragments, and not compilable in its original form. (For example, most Java answers don't have imports, class declarations, etc.) If code can't be compiled, it is not possible to identify out-of-date usage reliably and automatically.

Even if it was possible, it would not be advisable ... to automatically remove or replace such code. A lot of people use old versions of programming languages, libraries, etc. It is not a good idea, but it is often necessary. If we (say) ripped out all example code for Java 7 and replaced it with Java 8 code, then a lot of people would not be able to find answers that help them.

In theory, if we could tag answers with a programming language and version, then it would be possible for a user to filter out solutions with "out of date" code. But getting to that state from where StackOverflow currently is would be a lot of work. And most of the work will be people trawling through the millions of existing answers and tagging them. Carefully.

I think a better approach is to educate users to not expect that they can copy-and-paste solutions without thinking. That's not StackOverflow's real purpose ... according to my understanding.

3
  • agree stephen tagging with version is one way to resolve this but my point here is for those answer which are useless for current versions for e.g version 2 code not supported for version 3. What should we do for that case ? if its beginner how can they differentiate since i am beginner in swift how do i know which code is of correct version n which is not
    – user6457240
    Commented Oct 7, 2017 at 1:20
  • 3
    You can add a comment to the Answer; e.g. "this answer doesn't work in Swift 3 or later". The beginner can then read this comment. Better still, once you have sufficient rep you can edit useful information like this into the Answer itself.
    – Stephen C
    Commented Oct 7, 2017 at 1:50
  • 3
    "sufficient reputation for edit" is 1... even less than needed to comment. Commented Oct 7, 2017 at 4:04

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