We like to encourage posters to paste their code (see How to force new users to post their code?). Unfortunately, sometimes we end up with "wall of text" syndrome, where some posters post a poorly-formatted 200-line class riddled with comments, debug statements and methods that have nothing to do with the issue.

Is there something that we can do to enforce/encourage them to clean up their code (for their own sake as well!) when asking questions in SFSE? There are two interesting references that we could quote: https://stackoverflow.com/help/mcve and http://sscce.org/

And, more specific questions:

  • should we ask posters to clean their code, pointing to the above resources?
  • should we edit posts and remove irrelevant parts of the code sample (comments, debug statements and irrelevant methods)? or is that considered rude/impolite or tampering with evidence?


2 Answers 2


Just my two cents:

  • Remove comments, debugs, and css without prejudice. Unless JS is actually relevant, yank it too.

  • Beyond that, it gets harder to tell, but if I am >99% confident some code doesn't pertain to the question at hand, I remove it.

  • If there is nothing but code, I drop a comment asking to add some description.

  • If you can scan the code for more than a minute without even gaining a basic understanding of what's being asked, it probably should be more concise.

  • If the code is long enough to force scrolling, there is little to no description, and it does not seem like I can cut it down myself, I immediately vote to close. Off Topic > specific problem.

  • 3
    Thanks for the useful guidelines
    – mkorman
    May 25, 2016 at 8:04
  • 3
    @Adrian Larson - I agree with your comments there, it makes sense to take out all the noise of comment lines, debugs, etc.
    – Dave Humm
    May 25, 2016 at 10:18
  • 3
    I agree with everything you've said here, just a couple of considerations - developers who're new to writing code may struggle to decide what's relevant and what isn't, a moderator can help here. It might be helpful to leave debug lines, which the submittor's used to test their code, in the code as long as they explain what the result was. In case they're misinterpreting what was printed or the line's in the wrong place and would never give the answer they're looking for.
    – Alex S
    May 25, 2016 at 16:06
  • 2
    @AlexS The thing is, we often see a comment like //update records right before a line like update records.
    – Adrian Larson Mod
    May 25, 2016 at 16:11
  • @AdrianLarson yes, I agree that comments, css & (the majority - see my previous comment) of debug lines should always go. I meant that new developers might have difficulty figuring out which lines of code to remove, without deleting the line that's causing the issue.
    – Alex S
    May 25, 2016 at 16:14
  • 1
    Indeed, that is the challenge. For those who are struggling to pare their content down to what is needed to solve the problem, the process itself is a great teaching tool, and I do try to nudge people towards it when I think it might help.
    – Adrian Larson Mod
    May 25, 2016 at 16:31
  • 1
    Adrian - a slippery slope here on going in and editing code -- besides the paring out of irrelevancies, one could also rename variables (such as the delightful opps when associated to a Quote; or accList when associated to a singleton Account) but I lean towards posters should clean up their own mess and answers are the place to show tight/concise/best practice code, with ellipsis (// do stuff ...) used to substitute for OP's noise where appropriate.
    – cropredy
    May 25, 2016 at 16:56
  • @cropredy My general rule is if it's not obvious, don't do it.
    – Adrian Larson Mod
    May 25, 2016 at 16:58

I'm of the school that my and the community's time is too valuable to waste on editing an OP and stripping out irrelevant code. I don't mind doing a bit of editing if the poster hasn't realized that some of the code missed the formatter, but I won't pretty print their code or strip out noise and obfuscation.

Although it might seem like 'educating questioners, one OP at a time', I like to point to the sssce.org via putting in a comment using [ask] in the comment text.

As we all know, sometimes a poster will ask, over a period of time, multiple questions, so, best to get folks into the best practice right away. In addition, when a poster can go back and edit their question through our gentle, yet firm prompting, they have the opportunity to reflect once again on their issue and perhaps self-cure through reductionist testing - thus, making themselves a smarter SFDC developer/admin.

  • 2
    I agree that you shouldn't have to spend too much time tidying up others code. But I like Adrian's suggestion that reviewers add more specific comments - detailed in his answer - where they're not listed in sssce.org guidelines.
    – Alex S
    May 25, 2016 at 16:10

You must log in to answer this question.

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