-7

For example, when I look at this accepted and popular answer, it takes me additional time to see the main solution. It is hidden between the short explanation and, at first sight, the reference link seems to be the way to go. In comparison, the more formatted code in the second answer can be grasped more quickly.

Should essential code be on a separate line and/or is editing this considered useful?

2
  • You could just take the time to read the one line that precedes the link.. Commented Apr 25, 2015 at 22:55
  • 2
    Sometimes using the back-tick is actually useful. It is here. Commented Apr 25, 2015 at 23:18

2 Answers 2

6

Your mistake is in thinking that the essential part of an answer is the code. It's not (or at least, should not be). Stack Overflow is a site for sharing knowledge, there are plenty of other sites for sharing code.

Of course you are right that the code is hidden in the text. It's a problem only because the text is conversational filler, with no information whatsoever except the code.

All the answers on that question are garbage, none of them contains any explanation at all. There's is, attr, and prop, and none mention what the difference is, or the pros and cons of each.

11
  • Do you really need to further explain those 10-20 characters of code other than saying: "Use <code> to determine whether or not it's checked"? What more is there to explain, even?
    – Cerbrus
    Commented Apr 25, 2015 at 23:08
  • @Cerbrus: Was my last sentence unclear?
    – Ben Voigt
    Commented Apr 25, 2015 at 23:09
  • That sentence was the reason for my comment. There's literally nothing more to say than what's in those answers. It's simply what those tiny snippets of code do.
    – Cerbrus
    Commented Apr 25, 2015 at 23:10
  • @Cerbrus: The answers do not tell me what the tiny snippets do. They do not tell me that one is a test for the :checked pseudo-class and another is a test of the checked attribute. (At least, I assume that is the difference... the answers should not leave me making assumptions.) They do not tell me whether one method is preferred, maybe because it is faster, or more portable. Your "literally nothing more to say" couldn't be more wrong.
    – Ben Voigt
    Commented Apr 25, 2015 at 23:13
  • Fine, correction: "There's literally nothing more, of significance, to say". In the end, both functions work the same way. There's no significant difference in support, speed, or functionality. Except that one can be used as a setter, which is explained, there.
    – Cerbrus
    Commented Apr 25, 2015 at 23:18
  • 1
    @Cerbrus: "There's no significant difference" is itself a significant statement.
    – Ben Voigt
    Commented Apr 25, 2015 at 23:21
  • Imo, not significant enough to call answers lacking it "Garbage". (I'm not saying they're great answers, let that be clear)
    – Cerbrus
    Commented Apr 25, 2015 at 23:22
  • @Cerbrus: No, the reason I called them garbage is because they do not say how they work. Just "here is code that (solves your problem)" (at least the problem is resummarized). I haven't done web development in years, but I have this sneaking suspicion that, despite your claim that "both functions work the same way", one is actually dealing with style classes and the other with attributes, which are not the same thing.
    – Ben Voigt
    Commented Apr 25, 2015 at 23:26
  • :checked really has nothing to do with style (/ classes)... Only with the element's state.
    – Cerbrus
    Commented Apr 25, 2015 at 23:28
  • @Cerbrus: So it's not actually inspecting the CSS :checked pseudo-class ?
    – Ben Voigt
    Commented Apr 25, 2015 at 23:30
  • It's a pseudo-class also used for styling, sure. What I mean is that .is(':checked') has nothing to do with styling.
    – Cerbrus
    Commented Apr 25, 2015 at 23:36
3

Imo, the piece of code you need is easy enough to find in answers like that. Especially since the link says "More information here", implying that the link is just extra.
When looking for answers, it's usually a good idea to actually read the answers, instead of blindly clicking the first link you see. Especially considering the fact the answer is very short. It's barely 2 lines of text and a link.

TL;DR: Answers like that are fine. Don't edit them.

2
  • In instances like the above, intended or not, to me SO serves like a reference guide. I think users often search for a snippet the have already used and just need a reminder, what is was. Does the suggested formatting increase readability? I think so. Objectively? Mmmh. If it does, is the difference large enough to talk about? Dunno. Fair enough: Not reading an answer is certainly a bad habit and if it leads to misunderstandings, it is a users fault. Still, I sometimes use SO just to get / remember a function name or so.
    – SunnyRed
    Commented Apr 25, 2015 at 22:44
  • And the function (/name) is right there in the first line of the answer. I really don't see why that answer, or answers like that would need to be edited.
    – Cerbrus
    Commented Apr 25, 2015 at 22:45

You must log in to answer this question.

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