Are questions asking about the purpose of a particular snippet of code within a non-documented, well-known library/package/repository (e.g. DeepSort) within the scope of the site?
-
14Related: How to handle "Explain how this ${code dump} works" questions– BDLCommented May 29, 2023 at 16:49
-
9Maybe, maybe not depending on how broad of an explanation is required. But even when it is on topic expect a few, "Have you stepped through it with a debugger?" comments.– user4581301Commented May 29, 2023 at 18:18
-
2Even if they are, I give such questions very little chance of being well-received. They are not useful to other people, they are more curiosity questions.– GimbyCommented May 30, 2023 at 7:04
-
1What do you mean? You talk about a question, regarding a code snippet inside some library and as a reference you mention the entire library itself.– DominiqueCommented May 30, 2023 at 7:36
-
@Dominique I see. I misplaced the e.g.– Mehdi CharifeCommented May 30, 2023 at 17:14
-
5Questions are required to be self-contained. If the full context necessary for a subject matter expert to understand the question and provide an answer isn't in the question, then it's off-topic and should be closed (typically as "unclear"/"needs details or clarity", but for debugging questions, "needs debugging details" may be more specific). [This is just a general statement of the limits of scope for the site and shouldn't be taken as saying if the type of question being asked about is on-topic or off-topic when the necessary context is fully contained within the question.]– Makyen ModCommented May 30, 2023 at 17:31
-
1@Makyen So if I include all the the snippets of code that call or are called by the snippet of code in question, the question would be on-topic?– Mehdi CharifeCommented May 30, 2023 at 17:34
-
5@MehdiCharife I thought I was really clear that I wasn't making a statement about that. I was just stating that if it's necessary for subject mater experts to go off the question page to get context about the question that's not in the question in order to answerer, then it's definitely off-topic/not in scope for the site.– Makyen ModCommented May 30, 2023 at 17:38
-
6I understand. So being self-contained is just a necessary, though not sufficient, condition for being on-topic.– Mehdi CharifeCommented May 30, 2023 at 17:40
-
2Well. That explained what the ubiquitous SME stands in for. I had the context figured out, but not what it actually acronymized.– user4581301Commented May 30, 2023 at 18:41
-
2Side note: SME is one of the entries in the Stack Exchange Glossary - a resource which has helped me understand much of the terminology I see on Stack Exchange and Stack Overflow. @user4581301– andrewJamesCommented Jun 1, 2023 at 13:02
-
1I absolutely think this is correct. Furthermore, if it's not allowed, people could just try to 'sneak' a question in via a 'flaw' in the code, and ask indirectly.– JosephDoggieCommented Jun 1, 2023 at 15:06
-
2In addition to including the complete snippet they are wondering about so the complete context is self-contained I also try to get the OP to explain what specific part of that code they are struggling to understand, any specific part that isn't meeting their expectations.– Drew ReeseCommented Jun 1, 2023 at 15:14
1 Answer
Questions asking what a snippet of code does are OK as long as the snippet includes enough code to be reproducible (as Makyen mentioned in comments above, if I have to go off-site to find the answer, then the snippet/question is not self-contained and reproducible. You can't expect users to guess at what type a variable may be or what its contents are if it is not declared in that snippet, or what a function call will do if that function's definition is missing, for example.
Questions asking why a snippet of code was written a certain way or included where it was may not be OK depending on the specific question being asked. We can't guess as to motivations behind design decisions.
-
2What's the point of asking what the code does, rather than just trying it? The question really needs to be something more specific, i.e. why it did X instead of Y (with an explicit Y!) in circumstance Z. Commented Jun 2, 2023 at 2:46
-
1@KarlKnechtel Running code doesn't always tell you what the code does. In fact I would wager that running most code won't tell you what it does. If it did, we also would never need things like code comments or explanations in answers; we'd just prefer code-only answers here.– TylerHCommented Jun 2, 2023 at 14:06