8

Are improvement questions allowed based on code along with a description of what OP is aiming for

For example in its most basic sense:

Is there a better method/more efficient way of writing this piece of code?

String printing = "Stack overflow"
System.out.println(printing);

I am trying to do so on and so fourth

I know this may lead to:

User one: Do this

User two: You could do it that way like User one said but you could also do it this way

User three: User one and two are wrong, do it this way

However my argument is

  • The comment section is for constructive feedback, User three could express to User one and User two why it may not be as efficient or as usable as User three's method of implementation
  • User one, two and three's feedback to OP could all have an improved feedback on OPs original question
  • In a childish case, users become arrogant or even end up in a heated debate, their comments are removed which violate stackoverflows policy

I don't know if questions like this are allowed, if they aren't I have voiced my opinion and if you agree or disagree, comment why

If questions like these are allowed then kindly reply with an answer that I can gracefully accept and move on :)

According to snb's answer:

Foxhound:

Well I did use the term "in its most basic sense" in relation to your answer " attempted to displayed considerable effort ", furthermore the user in said example would provide all required info (" specific architecture, compiler, etc") along with an already working version of their code

1
  • 'already working version of their code'. OK. would that include a test spec so that alternatives could be presented as equivalent in functionality? Does 'writing this code' mean actually writing it, (which is trival), designing the code and data, testing, debugging, verification? Does the 'better' code use less memory or less CPU? Does it need more than one core that could be better used elsewhere? No. Such questions are inevitably under-specified, and, should sufficient info be provided for an answer, would be grossly too broad. May 20, 2017 at 8:21

2 Answers 2

8

Asking for "better" options is generally too broad question. May be suitable for http://CodeReview.stackexchange.com if asking to make working code generically better.

To make such question on-topic for Stack Overflow you need to define criteria to improve very clear and demonstrate what you've tried, why your approaches did not solve the problem and preferably good reason why you believe goal is achievable. I.e. asking why your collection seem to be sorted at O(n^2) with standard sort methods when you expect O(n log n) is reasonable, but asking to get such sorting to O(n) or less is not.

Most likely "make it better" question also need specific measurements (timing, code complexity, code coverage or whatever you need to improve) along with specific goals.

3
  • please read the edit at the bottom of my post, however I understand where you're coming from in relation to "too broad" however, the edit nullifies that issue in accordance with snb's answer, also I notice you say "did not solve the problem" however my code relates to users with code that already works and does what they want
    – Sigh
    May 20, 2017 at 2:15
  • @Foxhound if your question is "can one write specific enough question about code improvement that it is on-topic for SO" - than yes, but finding reasonable sample of such question is very hard in relation to hundreds failed attempts. If you have practical reasons to ask such question - turn it around and ask why code does not achieve goal you reasonably believe it should. May 20, 2017 at 2:27
  • @Foxhound question has to have a problem to solve. In case of valid "make it better" questions the problem is "code XXXX does not achieve goal YYY" - so OP is expected to demonstrate effort in solving that problem and also understanding why/how those attempts failed. May 20, 2017 at 2:29
5

I don't see this as a proper question for SO unless you ask computationally faster. Even then, with out specifying a specific architecture, compiler, etc, the question would be too broad or possibly opinion based for it to be a proper SO question, and if you haven't attempted to displayed considerable effort to research this yourself it's doubly inappropriate to ask here (since it could take a lot of effort to answer).

I feel this likely will end up violating the posting guide lines unless you've tested several methods of speed yourself, and are asking why something is faster in one instance than another.

You should only ask practical, answerable questions based on actual problems that you face. Chatty, open-ended questions diminish the usefulness of our site and push other questions off the front page.

Your questions should be reasonably scoped. If you can imagine an entire book that answers your question, you’re asking too much.

and :

What topics can I ask about here?

...

  • a specific programming problem, or

...

  • a practical, answerable problem that is unique to software development

We already have code review and software engineering, so if your question is in the realm of "better" with out regards to performance but in terms of SE quality, then those are the places to ask those types of questions.

2
  • Well I did use the term "in its most basic sense" in relation to your answer " attempted to displayed considerable effort ", furthermore the user in said example would provide all required info (" specific architecture, compiler, etc") along with an already working version of their code, I'm discarding your answer since it falls within the spectrum of "a practical, answerable problem that is unique to software development" Read my edit
    – Sigh
    May 20, 2017 at 2:11
  • I have often been in a situation when I'm new to a popular software library and want to solve a specific problem. While reading the documentation and looking for a recipe, the best idea I come up with is some ugly, hack-ish approach that I don't want even to actually code. There seems to be a high chance that a person with good knowledge of the library might be able to solve the problem nicely in a few lines of code. But when I ask a question on SO about solving the problem properly, the question gets downvoted for both not showing my own attempts and for being too broad. Jan 27, 2021 at 10:29

You must log in to answer this question.

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