40
\$\begingroup\$

While Stack Overflow questions often contain segments of pseudocode or purposely abbreviated code in order to make the question more palatable to other readers, for something like a Code Review, the asker is generally going to have to post their actual code that composes a given system (otherwise the code review itself is kind of null).

I can see plenty of cases where this could easily lead to several hundred lines in a typical posting. Shorter reviews (i.e. 5-4 lines of code, and a question like "should I use X or Y to accomplish task Z?") should be posted on Stack Overflow instead, as such questions generally pertain to use of specific language features, or syntax attributable to a given language, not to the design of a system or it's code.

Is it appropriate therefore for code listings to be longer in a Code Review question? If so, how long before we would call a system unreasonable for a question and answer site?

\$\endgroup\$

5 Answers 5

21
\$\begingroup\$

It does seem inevitable that large(ish) blocks of code are going to be the norm here. I guess inevitability equals appropriateness in this case.

Having said that I think we should encourage a guideline that says "be concise, but not too concise". Perhaps this could be a part of the FAQ discussion.

As for what the ideal length is, I think we'll have to judge that on a case by case basis.

As an interesting note: my first answer to a question boiled down to "break it up - it's too long". Based on the votes I'd say a lot of people agreed with me. I guess that ties to what I'm saying about encouraging a little conciseness

\$\endgroup\$
3
  • \$\begingroup\$ I completely agree. Perhaps over time we will assemble a few points that can be outline for what are good ways to make your code concise? \$\endgroup\$
    – Jeremy
    Commented Jan 20, 2011 at 13:38
  • \$\begingroup\$ @Jeremy, even some "shining examples" from real questions \$\endgroup\$
    – LRE
    Commented Jan 21, 2011 at 3:54
  • 3
    \$\begingroup\$ The problem I'm seeing already is not with large reviews, but with things that are <=5 lines of code. I don't think those really belong here since its such a small isolated thing. \$\endgroup\$ Commented Jan 29, 2011 at 23:45
12
\$\begingroup\$

There is no actual limit for posted code, aside from a few limiting factors:

  1. Character Limit.
    All SE-Posts are limited to 30k characters (including markdown) Contrary to the usual network-wide restriction of posts to 30k characters, Code Review supports a whopping 65k characters for all posts
  2. Description. It is considered good practice to describe what your classes do, describe the use-case of your project, illustrate what exactly you want reviewed, have a nice structure, get the reader to actually read your post.

And that was about it. Keep in mind though:

  1. The longer your code is, the longer it will take to review (understandably)
  2. If your readers get bored, they won't review your code. Reserve enough space to keep your readers interested.

In addition to that, as rolfl correctly mentioned in a comment:

Note that large code dumps tend to generate high-level reviews. Small code blocks tend to generate in-depth, technical reviews.

\$\endgroup\$
3
\$\begingroup\$

I am thinking that the number of edits should be more for this site. If they do post what they want to be reviewed and someone asks the OP about a part of their code that the OP thought was not relevant to what they were wanting to review, that could get rather lengthy as well. And I do agree; I don't think that everyone is going to want to put all their code on one post, so allowing someone to add code to the post to clarify different portions of code is something that we should look at

\$\endgroup\$
3
\$\begingroup\$

One core aspect of the code review process is exactly that: To review whether the code is too long for the functionality it encodes. So, I think putting an arbitrary limit on the lines of code will nullify one of the most basic purposes of code review.

On the other hand, I don't think any sane person will post 10,000 lines of code up for review. I think, in overwhelming majority of cases it's safe to rely on the OP's judgment on the reasonableness of his/her request.

\$\endgroup\$
1
\$\begingroup\$

I don't think there is an appropriate length, since everyone's code is going to be different, but I think there is appropriate content.

As long as they include their code and a quick explanation of what the code does (so nobody has to read through it and assume things), then it should be fine for Code Review. Common sense will probably dictate whether or not the code is too large to be reviewed here.

\$\endgroup\$

You must log in to answer this question.

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