-13

I recently asked a question about a coding problem to which I had several possible solutions, and I was asking which one would be considered best practice, or if any of them would be considered problematic (Best pythonic practice to pass many redundant parameters from module to module). The question got closed as opinion-based, which I am not objecting to; I understand where that comes from. I ended up flipping a coin and implementing the one that seemed faster to do.

However, I would like to clarify whether it is all questions of the type "what's the best practice for doing X" that are considered opinion-based, or if it was just the framing of that specific question that was not specific enough. I am confused, because another of my questions of the same type got a few good answers earlier, and didn't get closed (How to provide two different ways to instantiate). Though that previous question was probably better-defined and thus overall easier to answer, I cannot tell what made it less opinion-based per se, so I'd like to clarify the criteria.

I would find it a pity if all questions of that type are banned, because as a self-taught guy, most of my problems are within that realm. I can almost always figure out a way or several to achieve what I want, but it is usually very hard to know which one is going to lead to maintenance problems or obscure glitches down the road without the opinion of more experienced developers.

15
  • 1
    Please check out this Google search link for some related (and some unrelated) meta questions and answers: site:meta.stackoverflow.com best practice. Aug 16 at 12:48
  • 10
  • I did see there were a few questions on the topic, but they did not really bring a clear answer to my confusions: why was my older question about best practice accepted and answered, vs what made the more recent one opinion-based. I also did want to throw in the GPT situation in the discussion even if it is not the main focus, I think it is a point to consider. Finally, the answer you linked to suggests that "best practice" is often a low-effort umbrella term hiding a lazy question. However, my question did include solution proposals and my reasoning, so I don't think it falls victim of that Aug 16 at 12:57
  • 9
    Regarding the aside "factual and objective robots are becoming better" GPT is not factual / objective it is a large language model which is good at predicting plausible sounding messages given a prompt. Aug 16 at 13:00
  • Right, what I meant was that I do think from my personal experience with it that it does a remarkably good job at answering factual and objective questions/accomplishing objectively defined tasks (in fact, I don't find it very good at anything else yet), and is especially efficient at proposing ways to achieve a coding objective, and answering coding questions of the type "how do I do X" (with a bit of trial and error). It sucks, however, at answering "I could do it this way or that way, which one is preferrable?", and that's where a community of humans is still largely better than it Aug 16 at 13:04
  • 12
    "factual" and "ChatGPT" do not belong on the same page. Everything in a ChatGPT response must be independently verified. Most ChatGPT responses contain sections that are correct and sections that are completely made up. Aug 16 at 13:15
  • I would disagree that "factual" can not be written in the same page as chat GPT since, personally, the most (and kind of only) satisfying use case of GPT I could find so far is to ask it objective and factual questions, usually as a starting point before a more thorough check, or to give it objective writing tasks. But again, the main focus of the question is not the general feeling of the SO community about GPT Aug 16 at 13:18
  • 7
    I think it's important to be aware of the fact that the community's attitude towards LLMs is ... not positive. Any hint that LLMs might actually be useful in any way, or that some site policies should be evaluated in the light of LLMs existing, is not going to be well received. I would strongly suggest removing any mention of LLMs from your question (including the tag), because that will become a focus of your question, whether you want it to, or not.
    – cigien
    Aug 16 at 13:39
  • 8
    @cigien Agreed--this isn't really a question about ChatGPT so I removed that tag and the aside altogether.
    – TylerH
    Aug 16 at 13:56
  • 1
    Related: meta.stackoverflow.com/questions/296542/…
    – TylerH
    Aug 16 at 13:57
  • 1
    "or if any of them would be considered problematic" - that's a better question than searching for "the best", IMO. Problems can be measured and exposed, but when it comes to what is the best... that may involve fists.
    – Gimby
    Aug 16 at 14:07
  • 1
    @gnat No, this question involves queries about OP's own specific questions; it's not just about whether best practice questions are allowed, or really about that at all, since OP acknowledges and accepts the closure of their best practices questions.
    – TylerH
    Aug 16 at 15:34
  • 1
    "best practice" is subjective, however "most practiced" is not, and IMO should be ok, however this is SO, all we care about is expressing political opinions via usernames.
    – mxmissile
    Aug 16 at 15:54
  • 1
    What is best? Aug 16 at 16:24
  • 1
    @mxmissile kind of hard to prove what is most practiced though. It'll still attract guesswork based on personal preference.
    – Gimby
    Aug 17 at 9:40

2 Answers 2

15

I would like to clarify whether it is all questions of the type "what's the best practice for doing X" that are considered opinion-based.

Yes.

Most people, when answering, are going to provide the answer they believe is a best practice... and if it's not, they should say so. Many "what's the best practice for X" questions are just "how do I do X" questions in disguise... and "how do I do X" is just fine.

If you instead ask "how do I do X", then you can spend some effort focusing on real, practical concerns that should ultimately lead you to best practices, anyway. For example:

  • Do you want to prevent a messy situation in the future where you might need to add more methods?
  • Is there a file-size constraint or time window your code has to run within?
  • Is there a potential to lead to undefined behavior or exceptions you don't want to have to handle?
  • Do you need to provide legacy support? Or vice-versa, and want to ensure your code doesn't cause deprecation flags/warnings for as long as possible?

I am confused, because another of my questions of the same type got a few good answers earlier, and didn't get closed ("most pythonic way to provide two different ways to instantiate?"). Though that previous question was probably better-defined and thus overall easier to answer, I can not tell what made it less opinion-based per se, so I'd like to clarify the criteria.

There's a bit of a misunderstanding there. That second question was still opinion-based, and the only reason it didn't get closed is that people who curate/close questions just didn't see it. The Python community on Stack Overflow is one of the more well-known communities for ignoring that problem with questions. For your benefit, I edited that second question to remove the opinion-based language.

Notice how, at the end of the question, you mention a practical concern ("that's not clear from the user's POV and might lead to undefined behavior"). That is a practical, specific concern that can be addressed objectively... there's no need to throw in a red herring of "best practices" here when you have such a clear concern!

I would find it a pity if all questions of that type are banned, because as a self-taught guy, most of my problems are within that realm. I can almost always figure out a way or several to achieve what I want, but it is usually very hard to know which one is going to lead to maintenance problems or obscure glitches down the road without the opinion of more experienced developers.

If you have a way to do what you want but just want to know how to make it the absolute best it can be, we actually have a sister-site exactly for that: Code Review. You take your full, working code there (like a Minimal Reproducible Example, except less Minimal) and post it and users will provide feedback, including opinions, on what you can do to improve it.

9

However, I would like to clarify whether it is all questions of the type "what's the best practice for doing X" that are considered opinion-based, or if it was just the framing of that specific question that was not specific enough.

They are all opinion-based. This is pretty clearly laid out in the help centre.

I am confused, because another of my questions of the same type got a few good answers earlier, and didn't get closed (most pythonic way to provide two different ways to instantiate?).

Almost all content moderation on the site is done by volunteers - anyone who has accumulated enough reputation for the relevant privileges. Most reputation comes from answering questions, which is relatively easy for experienced programmers - especially if they don't care about the site's standards for questions. Thus, there is no guarantee that the people who evaluate a question, actually have any understanding of the site's standards.

In general, "curators" (people with editing and closing privileges who actively use them) are counseled to edit questions to fix them where there's a clear fix that doesn't require information from the OP, and vote to close questions where that doesn't apply.

Regarding your previous question, it has since been edited to fix the issue of subjectivity. Answering that question doesn't really require comparing techniques, quoting best practices, etc. The requirement can be stated reasonably objectively: you want a technique that allows the user to avoid ambiguity between the a and b values, and there aren't a lot of options (if the ambiguity isn't resolved by the name of the parameter, it will have to be resolved by the name of the function that creates the object - i.e., by using a classmethod factory instead of __init__).

Regarding your current question, "passing parameters between modules" isn't really a proper description in the first place (presumably you are passing them to a class or function that is defined in a different module?) and the task is definitely not well specified (in the abstract, it seems like you are looking for ways to "bundle" parameters together, and there are any number of ways to perform the bundling - and for any given set of parameters, one could debate which parameters should be bundled together, whether to bundle the bundles, etc.) It also isn't clear why it should be relevant that the code being called is in a different module: code within the same module could just as easily involve functions with a large number of parameters that call each other. In short, it isn't feasible to advise in general, and what little advice can be offered is highly subjective.

I would find it a pity if all questions of that type are banned, because as a self-taught guy, most of my problems are within that realm.

Stack Overflow is not a discussion forum or any kind of tutorial resource; we want Q&A to show things that someone else can look up to get a quick, direct, objective answer. We don't want open-ended philosophical discussions, because the next person who comes along is going to be in a slightly different situation, say, with a totally different complex set of parameters for which a different bundling makes sense, and the general principles will be hard to extract. Questions like this also don't usually make a good search target (what would you put in a search engine?).

1
  • 2
    Thank you for providing a bit of Python SME insight into OP's questions and their problems as well--that's something I was unable to provide :-)
    – TylerH
    Aug 16 at 15:46

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