2

If I understand, the purpose of this community is to have useful questions and answers for current users of the relevant software/code. Some questions/answers sometimes contain obsolete code that has no direct bearing on the question (e.g. pertaining to an older code syntax that has been deprecated, is therefore not directly useful to current users, though it may well have another purpose, e.g. tracking version history).

[EDIT: added the bit 'that has no direct bearing on the question' to clarify]

Should we (basic users, moderators) strive to update obsolete code wherever it can be?

I have in mind questions with a high vote count and, naturally, code that would still be relevant after a few modifications.

At times, updating may not be possible. Example: a user asks how to do something, the accepted answer details a 200-line workaround, then a new answer points out that in the current version of the software, do_that() will do it and more. In this case, it is probably best to leave the question/answers untouched. My question pertains to other cases, where an update of the code would keep the question/answers relevant to today's code syntax.

Example to fix ideas

This question currently has 143 votes, so it must get a lot of 'views'.

Rotating and spacing axis labels in ggplot2

In the question, the code is:

data(diamonds)
diamonds$cut <- paste("Super Dee-Duper",as.character(diamonds$cut))
q <- qplot(cut,carat,data=diamonds,geom="boxplot")
q + opts(axis.text.x=theme_text(angle=-90))

This is now obsolete, with the current syntax as:

data(diamonds)
diamonds$cut <- paste("Super Dee-Duper",as.character(diamonds$cut))
q <- qplot(cut,carat,data=diamonds,geom="boxplot")
q + theme(axis.text.x=element_text(angle=-90))

Interestingly, the answer (+182 net votes) has already been updated to the new syntax, creating a 'disconnect' between question and answer, and furthermore making it seem like the answer is offering to 'update' the code where its main purpose is not about updating the code but about rotating labels in a plot. Both question and answer are relevant to the current version of the ggplot2() syntax.

Should I suggest an edit like the one above and, crucially, should a moderator accept it?

12
  • 1
    In most cases for question that have a good amount of views code is updated. We should update code as the point of Q&A is to help both the questioners and viewers of the question. Commented Jan 6, 2015 at 7:31
  • @SpencerWieczorek, thanks for the feedback. If that's the community's spirit, and I find it reasonable, I think it would be useful to have it stated explicitly as an answer below, in the form of a brief guideline, so moderators may be referred to it in case of doubts about what to do.
    – PatrickT
    Commented Jan 6, 2015 at 7:50
  • 1
    There is no such thing as "obsolete" code. Just because you're not using that version any more it doesn't mean that no one else is. If something is version specific, then edit to add the version ranges it's valid for, not to change the code.
    – Ben
    Commented Jan 6, 2015 at 8:07
  • @Ben, I beg to differ. "There's no such thing as obsolete" is not operative here if only a small/negligible/dwindling percentage of users are using the old version and the standard answer would be "ugrade to the latest version." Also the question you refer to is about "obsolete" questions and answers, but my question is about "non-obsolete" questions using obsolete code.
    – PatrickT
    Commented Jan 6, 2015 at 8:55
  • 1
    There is always somebody out there using the older version. We shouldn't take useful information away from them for no reason. If you have good info for a more recent version, either add an answer to the existing older question, or ask-and-answer a similar question which is specific to the new version of the technology. Commented Jan 6, 2015 at 9:33
  • 1
    I'm sure there are better, and answered, duplicates, with full discussion... Commented Jan 6, 2015 at 10:31
  • @ChrisHayes, let me rephrase to make sure I'm not being misunderstood, the questions I'm talking about ask "how can I do x", the answers state "this is how you do x", unfortunately the code contains obsolete bits that are irrelevant to the x-question. Are you suggesting that I should ask how to do x using the up-to-date code given that there are perfectly good answers to question x using out-of-date code? If so, someone will write "possible duplicate", and this time for good reason...
    – PatrickT
    Commented Jan 6, 2015 at 10:38
  • @Deduplicator, please do the right thing and post a link to the exact (or at least precise) duplicates.
    – PatrickT
    Commented Jan 6, 2015 at 10:39
  • @gnat, thanks for the link, that's quite close. Though I must say I am surprised by, and don't agree with, the accepted answer where it suggests not to fix missing code brackets and such: how can that be consistent with the stated goal of having the best questions/answers?
    – PatrickT
    Commented Jan 6, 2015 at 10:41
  • The suggestion to fix poor English syntax and/or choice of words to help readers understand the question/answer is in fact entirely analogous to the problem of editing obsolete code syntax, when the obsolete code syntax has no bearing on the question. so why is it considered bad practice to fix it?
    – PatrickT
    Commented Jan 6, 2015 at 10:48
  • @PatrickT Poor English is completely orthogonal to out-of-date code. There is always somebody stuck on an older version. Right now, somebody is writing code using the original release of Java. If the question is "how do I do X in R", then an answer is equally valid whether it uses R syntax v0.1 or R syntax v500. The only time it's not valid is when a specific version is called out, such as "how do I do this using Java 8 lambdas". Commented Jan 6, 2015 at 18:25
  • @ChrisHayes, yes, but to say it again: what if the obsolete part of the code is completely orthogonal to the question at hand? Say you ask on s.o. how to make the car turn right, and someone answers "take out the crank, put the pedal to the metal, then turn the steering wheel right", the o.p. then thanks "oh, the steering wheel, that's what it's for", then it's all upvoted a million times, then someone comes along and says "I can't find the crank", etc. that was my intended context. Anyhow, I've accepted an answer now and I feel like my question is now obsolete.
    – PatrickT
    Commented Jan 6, 2015 at 20:12

1 Answer 1

3

As people have said in the comments, there are stil people using older versions of software, even deprecated software. Therefore, I wouldn't change the code, but add something like:

in version X.Y.Z, ThisThing has been deprecated/changed. From this version on, a better way to do it would be:

ThisThing.newAndFancy('foo');
4
  • 1
    "there are still people using older versions of software" doesn't apply to my example, which was taken from R (open source) and the ggplot2 package, where it would be strongly recommended to upgrade if your version were older than 2 years (the case of the outdated code I refer to), but I like the idea of pointing out the version to which the deprecated/updated codes apply. Thanks.
    – PatrickT
    Commented Jan 6, 2015 at 14:10
  • @PatrickT Loads of people use highly outdated code. It's common in software shops (where it's not cost-efficient to update everything to the latest version) and in, for example, university research (where software is just a means to an end). I doubt there's any version of any mainstream programming language which isn't seeing active use today. Commented Jan 6, 2015 at 18:27
  • @ChrisHayes, thanks Chris, good point, makes a lot of sense for costly software, maybe R is special as it would be very unusual for someone to be running a version older than 2 years.
    – PatrickT
    Commented Jan 6, 2015 at 20:14
  • @PatrickT Generally the software itself isn't the issue (Java, for example, is free), but the time you have to invest in making sure nothing broke while upgrading versions, and/or in rewriting any software that requires it, and that all your libraries are still compatible.. That said, I'm not familiar with R, so it may be a different scene. Commented Jan 6, 2015 at 20:36

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