25
\$\begingroup\$

Every once in a blue moon, a question gets posted (often as a new user's first post) where the OP is asking a quite specific question about very minimalistic code, for example:

if (strstr($url, "?")) {
   $url = strstr($url, "?", true);
}

There is something to say about this code, of course. But does it qualify for a code review?

\$\endgroup\$
2
  • 10
    \$\begingroup\$ This is a legitimate question about the site's scope and what's on-topic and what's not. I'd really like to know why it was downvoted. \$\endgroup\$ Mar 3, 2014 at 4:24
  • 1
    \$\begingroup\$ This question was asked before, an older question now has an answer that demonstrates @rolfl's conclustion. \$\endgroup\$ Apr 2, 2014 at 22:42

5 Answers 5

13
\$\begingroup\$

Summarizing some chat, and other perspectives. Also providing more context than the 'counterpoint' answer I gave previously.

The 'Real Issues'

There are three issues at hand...

  • is there a threshold of 'enough' reviewable content? (and then, an obvious follow-up question is how-much is needed, and how is it measured...?)
  • whether questions like this add value to the site, or are 'noise'.
  • whether such questions should be closed as off-topic, down-voted, migrated, etc.

Additionally, there seems to be some agreement that the concept of 'short questions' is not the same as having enough 'reviewable content', but that there is some correlation... shorter questions tend to have less reviewable content.

Some Examples

The critical issue here appears to be hinging around a few common 'themes' or 'aspects' of (typically) short questions.

Either / Or questions

Consider this question:

Sometimes there is need to change an integer to text. I often use the following way:

"" + myNumber

But there is alternative way:

Integer.toString(myNumber)

Which one is better (performance, readability, safety)? Or are those equal?

Questions with little/no context

It is apparent that some people have been able to create answers even on the shortest question-code. @Mat's Mug has an example for this

Do they add value to the site?

It is apparent that these short questions can trigger a flurry of both answering and voting. They often hit the 'Hot Questions' list, and they can raise awareness. Whether these set a bad example for the site, or not, is debatable. But, they certainly generate interest.

Interestingly, short questions, because they are short, are also easy to answer quickly. This often allows new users to add answers without having to invest heavily in the full context of the problem. This is a good way for new users to get 'into' CodeReview.

Are these question on-topic?

Are these questions on-topic? In one sense, a question like this:

  • provides a context,
  • provides working code (when considered within the constraints of the context)
  • provides actual code
  • requests some input relating to performance, etc.
  • has the implied question with all CodeReview questions: I want feedback about any or all facets of the code?

It would, even though short, meet the requirements for on-topic on CodeReview. But the actual question asked by the asker 'Which one is better' is perhaps more suitable for Programmers.se... but... that does not mean the code is unreviewable. It means the asker can probably ask slightly different questions about the same code, on two SE sites.

This question has thoughtful, highly-voted answers, that not only answer the question about which one is better, but provide additional details and suggestions, and supporting facts.

Downvoting

Like always, downvoting is a way to indicate that the question was not well formulated. If you don't like the question, then downvote. If you don't think there is enough context, then down-vote. if you thing the question is unclear, then vote-to-close for that reason. If you think the answers will be opinion-based, then vote-to-close for that reason.. but, if there is content in the question that satisfies all on-topic requirements, then that part of the quesiton is on-topic, and thus the whole question follows.

Vote-to-close

Like always, if the question does not satisfy the requirements of CodeReview's On-Topic system, then vote to close. This is where it gets 'grey'.

But, if the question even minimally satisfies each of the on-topic requirements, then the question is on-topic (it could still be too broad, opinionated, etc.. though).

If you don't like the fact that an otherwise on-topic question does not enough context, then down-vote.... don't close.

Migrating

Some really short questions have been migrated from Programmers, and have been successful here. This question is obviously not on-topic there, and people here obviously found things to review (or upvote since not all the answerers joined after the migration).

Obviously, migrating is not a 'blanket answer' to these questions.

On the other hand, there have bene times when users have asked for their questions to be migrated (they did not want a review, they wanted an opinion). Other times questions have been answered skipping over the parts that are not reviewable. Some answers have done both reviews, and offered opionions.

Conclusion

In my mind, if there is any reviewable content (any code), and the question otherwise fits the on-topic requirements, then the question is on-topic.

Closing a reviewable question (no matter how bad the question), robs someone of the opportunity to answer anyway.

Feel free to down-vote if the questions should be improved..... (downvotes are free, unless you are at DVLR...)

Close if they are off-topic.

Ignore them if they irritate you.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ I've downvoted the regex question and left an explanation. \$\endgroup\$ Mar 3, 2014 at 19:25
18
\$\begingroup\$

As a counterpoint, here are a list of highly ranked, small-code questions that have high quality answers, and are generally successful:

I could go on, and on, and on (cherry-picking off this query on SEDE)

in each of these questions, the complete opposite of what Mat suggests may happen, did happen....

These short questions are to-the-point, they have long, detailed answers, that overall improve the quality of the site.

Small questions often highlight controversial or common problems, and invite experienced users to provide the best answers.

As for answering them with a 'mere comment', that is true for long questions as well as short questions.

The length of the question has no bearing on it's quality.

Finally, whether a question is on-topic or not, is not related to its length, but about whether it conforms to the requirements of being on topic.

Adding a requirement about code length to the on-topic system will be overly complicated, and ineffective. For example, what is to be said:

  • python programs must be at least 256 character, or 5 lines before they are on topic, but that is assuming they use tabs, not spaces for indents.
  • brainfuck programs must be at least 4 characters.
  • regex problems must have at least one grouping construct
  • COBOL programs need a .....
  • C programs must be at least twice as long as the same program written in perl
\$\endgroup\$
4
  • \$\begingroup\$ Could be worth noting that the query returns 1311 rows instead of 76, if where q.AnswerCount > 2 is commented-out. \$\endgroup\$ Mar 3, 2014 at 4:30
  • \$\begingroup\$ @Mat'sMug I wrote the query to identify where multiple answers happened (things which support the counter-argument ;-) . It is an interesting query that can be twisted for all sorts of effects \$\endgroup\$
    – rolfl
    Mar 3, 2014 at 4:31
  • \$\begingroup\$ @Mat'sMug Except that also includes answers. If I use PostTypeId = 1 instead, I get 178 rows. \$\endgroup\$
    – svick
    Mar 3, 2014 at 14:29
  • \$\begingroup\$ Ironically, one of the questions that were "cherry-picked", is locked and "is not considered a good, on-topic question for this site". \$\endgroup\$ Mar 3, 2014 at 14:33
7
\$\begingroup\$

I think these questions invite low-quality, short, code-only answers and decrease the overall quality of questions on the site.

They are too narrowed down on a specific issue and leave very few possible answers, and can be answered with a mere comment.

I think the ought to be closed, ideally with a "too narrow" close reason.


I have forked @rolfl's query and added some information about the OP and their participation.

71 of the 76 rows returned involve an OP with < 500 rep score, and none involve a > 1K user. 27 involve an OP that has given a sign of life during the past month, and 31 were asked after 2013-01-01 (6 in 2014).

What comes out of this quick analysis is:

  • A majority of these questions were asked in 2011-2012 when the site's scope wasn't as clear-cut as it is today.
  • 47 of the 76 were first posts.

This isn't about the length of the question, it's about the scope of a question.

When all the OP wants to know is how a tiny little piece of code could be written better, the purpose of the site is thwarted and Do I want feedback about any or all facets of the code? doesn't hold anymore, because there's only 1 facet to review.

The same applies to longer questions that fill up a switch statement with dummy code and ask how could I refactor this switch block?.

I don't think this is what the site was created for. We want questions that include an entire method, or an entire class - enough code to actually review something. Giving all possible ways of rewriting 2 lines of code doesn't constitute a useful "review".

The number of answers given on a question, and the votes these answers receive, don't make it on-topic either. It's not even because it's a poor question. There are very interesting questions that would be on-topic on Programmers.SE, that have to be off-topic here.

There are other programming-related sites in the SE family, and sometimes the boundaries are foggy between two or more sites' scopes - there's a level of overlapping that's likely to occur. We need to know where to draw the line where CR's scope ends, and when a question would receive answers that would be more relevant / on-topic on another site. If a question's best answer is not a code review, it's probably not a code review question.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Always, or sometimes? rolfl's answer seems to indicate that length alone is not a good criterion. Can you rephrase your objection to 'such' questions so that your objection is based on something other than (only) the length of the code? \$\endgroup\$
    – ChrisW
    Mar 3, 2014 at 3:42
  • \$\begingroup\$ @ChrisW added more info. It's not about the length of the code, it's about the scope of the review. \$\endgroup\$ Mar 3, 2014 at 4:19
6
\$\begingroup\$

Let's take a fictional example:

Sometimes I have a function that returns a Boolean, but I'll put a guard clause in the function to raise an error if a certain condition isn't met:

    If MyCollection.Count = 0 Then Err.Raise vbObjectError + 9999

Would it be better to just do this?

    If MyCollection.Count = 0 Then MyFunction = False : Exit Function

If this question was posted on CR, I think it's too narrow and should be closed as off-topic. Not only because the names are "generalized" and the thing looks like pseudo-code, but also because there's such little context, that leaving the actual names of the involved identifiers in there, is irrelevant. This goes against the spirit of "3. Is it actual code from a project rather than pseudo-code or example code?".

Now consider the same code, properly put in context:

I have this function that returns a Boolean when all "glasses" under a particular "pricing element" have the same width and height:

Public Function HasEqualGlass() As Boolean
'returns true if all glasses are same size (+/- ACCEPTABLE_MM_OFFSET).

    Dim glass As PricingElementGlass
    Dim lastHeight As Double, lastWidth As Double
    Dim isEqual As Boolean

    If this.ElementGlasses.Count = 0 Then Err.Raise vbObjectError + 9999, "PricingElement.HasEqualGlass", "Invalid operation: element does not have any child glass element."

    isEqual = True
    For Each glass In this.ElementGlasses

        If lastHeight = 0 Then lastHeight = glass.Height
        If lastWidth = 0 Then lastWidth = glass.Width

        isEqual = isEqual And Abs(glass.Height - lastHeight) < ACCEPTABLE_MM_OFFSET
        isEqual = isEqual And Abs(glass.Width - lastWidth) < ACCEPTABLE_MM_OFFSET

        If Not isEqual Then Exit For
        lastHeight = glass.Height
        lastWidth = glass.Width

    Next

    HasEqualGlass = isEqual Or this.ElementGlasses.Count = 1 ' return true if there's only 1 glass to avoid getting a "L" in the pricing code of a single-section model!

End Function

All of a sudden, a whole world of possible answers emerge; sure, the first version could prompt several interesting and useful answers, each making various attempts at explaining why A is better than B or vice-versa. With the whole context provided, not only reviewers can question whether raising an error is a good idea or not, they can also review a piece of working code, and raise points about many things other than what the first version would allow as answers.

Simply put, while both versions are perfectly good questions; both questions are short questions with very little code to be reviewed, and yet only one of these two "questions" is asking for code to be reviewed, and IMO only one of them should be on-topic on CR. Answers to the 1st version are not code reviews.

\$\endgroup\$
2
\$\begingroup\$

On StackOverflow all "please debug my code" questions are on-topic (<-- citation required); so for symmetry and completeness perhaps all "please review my code" questions should be on topic here.

If you don't want to answer too-simple questions you don't have to; but someone else might want to, so you needn't close them either.

FYI StackOverflow implemented this close reason to be used on questions after they have been answered (either answered with an answer, or answered with a comment).

decrease the overall quality of questions on the site

Allowing short questions could increase the total usefulness of the site (by making it useful to people who want to ask short questions); it may decrease the average quality-per-question (by allowing lower-quality questions).

\$\endgroup\$
1
  • 7
    \$\begingroup\$ perhaps all "please review my code" questions should be on topic here - that's the point: the question I'm referring to, is not asking for a review, rather how to further simplify/golf a one-liner. Some of the "cherry-picked" questions (and more, returned by the same query) are asking to compare A versus B comfort the OP in saying why A is better than B or vice-versa. That's not how I see a good "code review" question. Again it's not about the length of the question, it's about the scope of the review. I strongly disagree that this is the direction we need to be taking. \$\endgroup\$ Mar 3, 2014 at 14:43

You must log in to answer this question.

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