The Code Block appears to be the most common edit within Stack Overflow. It seems to be highly abused. Is this type of edit really warranted?

public class

     // Description of Method.
     public void IsValid()

            // Some Implementation.



Will end up be edited into this:

public class
     public void IsValid()
         // Some Implementation

Now in this instance it is quite small, so that condensing makes it legible still. However, more complex examples with a larger syntax are more difficult to read now.

  1. Because the descriptive comments tend to be removed.
  2. There is no spacing just raw indentation, which forces all to be stacked on each other.

I'm mostly curious if this is something that the community should address, because in some cases it is better to be descriptive so the syntax is easier to read from a novice to an expert. While still providing an adequate spacing, though it may appear to take up more space complex examples are easier to read.

What is the correct way? What is better practice so we can ensure that developers whom are starting learn the best practices so they are not only setup for success on Stack Overflow but a real world job as well.

Thank you.


There are no guidelines mentioned to good or bad coding practice for Stack. Currently users abuse the edit to gain reputation. But, by doing so in several instances it actually is considered bad practice.

As comments, and clear reading make it significantly easier to read. Obviously condensing is better on a mobile device; but when the condensing actually teaches poor practice is it truly something Stack should allow?

And as I stated above, there isn't a real guideline. It is essentially up to each individual poster.

If my suggestion to make this more clear for users is deemed poor, my apologies. However, it is an underlying issue that should be fixed as it isn't clearly indicated. It was wrong to state its abuse for reputation. But it is still abused a lot.

  • 16
    Anything to get rid of scrollbars! :-) – Arjan Feb 25 '13 at 22:32
  • 3
    I can't dispute that, the scrollbar is highly annoying. – Greg Feb 25 '13 at 22:34
  • It is a trivial edit if nothing else is fixed/improved, IMO. – Asad Saeeduddin Feb 25 '13 at 22:42
  • I agree it is trivial, but to new members or new programmers this can teach them bad habits. That is why I brought it up; as there are people who only edit those code blocks and change nothing else. Which I think can inhibit a new member or new developer from knowing the difference. – Greg Feb 25 '13 at 22:48
  • 3
    Also, less whitespace (and less indenting, and less noise from useless code comments) really makes things more readable on mobile. I don't find such edits too trivial. If folks are willing to fix it for some reputation (or none), then I'm thankful. – Arjan Feb 25 '13 at 23:05
  • It may be easier to read on a mobile device; but it doesn't tout good practice still. When you look at an application without any comments, nor clean legibility it is considered horrible practice. The initial point of my question is, by condoning these edits isn't it affecting good or bad practice. – Greg Feb 25 '13 at 23:17
  • 1
    I wrote useless comments. Like in your example that might be // Returns isValid. Delete. And in real code, I actually dislike all that whitespace too, and all standard formatters I've used were based on K&R-like styles, reducing each block with yet at least another line. So in my world, that's actually cleaner than the original, but that of course is a different discussion altogether. Any personal preferences aside, I truly think that code on SE should simply be as compact as possible, due to the site's limitations. – Arjan Feb 25 '13 at 23:29
  • Valid point, but this draws back to my original question. Wouldn't it be worth having this documented a standardized way rather then so many opinions? Not only is it not documented, it doesn't explain which could mess up a new developer as they aren't sure what is good or bad practice. – Greg Feb 26 '13 at 0:36

The Code Block appears to be the most common edit within Stack Overflow. It seems to be highly abused as a quick way to earn edit reputation and or roll back. Is this type of edit really warranted?

I'm not going to contend that it's likely the most common edit, but most of those edits occur from 2K+ rep users; they don't have to wait for the review for an edit that they would consider "minor".

Anytime I see an edit that just fixes syntax, and not correct any other glaring mistakes in the post, I usually reject it, or go back and fix the mistakes myself.

There may be a handful of people that do get reputation from those kinds of edits, and some reviews do fall through the cracks. But if you do catch a review like that, and it doesn't correct any other issues in the post, by all means reject it.

Now in this instance it is quite small, so that condensing makes it legible still. However, more complex examples with a larger syntax are more difficult to read now.

So, interesting thing about my code formatting edits: I use a project I set up in IntelliJ IDEA to do code formatting (Ctrl+Alt+L ftw), and my code style has rules that would format the above code like that. I've not felt that an edit like that is detrimental or "bad" - its intent is to make it more readable, and large tracts of whitespace isn't considered readable.

If you had an example of which this sort of edit was detrimental, that'd carry a bit more weight. I don't know or think that those sorts of edits are bad, though.

  • Your response answered the question in the best way. Thank you Makoto. – Greg Feb 26 '13 at 3:38

Users abuse the edit feature to gain reputation

You would need 50 approved suggested edits to get 100 reputation. I can (and did) get that in a single answer.

It happens to me often that I edit a question just to get all the annoying whitespace out of my eyes. It may seem minor, but it does help a lot when reading code.

Obviously, if a post has multiple other things to improve (grammar, typos, etc) I'd rather the user to actually do some work and improve those too. In those cases improve is my friend.

  • Thank you, that is a valid response. – Greg Feb 25 '13 at 23:35
  • But in a real world example, a real application. They often preach about white space to help separate code, indentation, and importantly comment a lot so others and yourself later on can still interpret the code. I only suggested and brought this up is there aren't clear guidelines mentioned in Stack. Some of these edits would annoy a boss in real world examples. Especially for highly complex examples. Isn't it our job to accurately reflect that? That is all I'm saying. If not, that is fine as well. But shouldn't we standardized it to avoid excessive edits to just remove white space? – Greg Feb 26 '13 at 0:00
Users abuse the edit feature to gain reputation

You can only get 1000 rep from edits and it would require finding 500 minor edits that will get peer reviewed. It isn't really the most effective exploit, and even then, 500 minor edits that are correct is welcome.

In any case, tidying up code formatting is a good thing because poorly formatted code is such a pain.


No, Stack Overflow does not and should not dictate coding style.

The issue of style transcends Stack Overflow. There are some best practices that most people agree with, but it's mostly a matter of opinion (brace style, tabs vs spaces, naming and casing conventions, line breaks etc.) . It also varies depending on what language you're talking about. It's not SO's place to decide what should be accepted as the "standard" or best practice for the industry.

Any edit that makes the code easier to read is a good edit, as long as it doesn't alter the functionality of the code. Sometimes it's removing empty lines, sometimes it might be adding them. Be careful removing comments. You have to take it on a case by case basis. If we were really here to teach best practices, then we'd end up writing docblocks for every method declaration, adding more comments, and all kinds of stuff that has no bearing on the actual question (not to mention refactoring the code itself, which you should not do to someone else's post).

No one is going to get rich with reputation by edits alone, it's tedious and takes more time than just answering questions (plus you're capped at 1000 points of edit-rep). Bad edits usually get rejected, and good ones help out the site. There are edit bans for people that have too many rejected edits. There's very little you can do to "abuse" editing.

Also if you ask me, best practices include not copy/pasting stuff from the internet into production code.

  • I'd +1 for the "no copypasta into production code", if it weren't so obvious as to be commonplace. – Makoto Feb 26 '13 at 3:30

You must log in to answer this question.

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