Has anyone written an Apex or VisualForce code style guide, in the way of the Ruby Style Guide or jslint, or PEP-8, or any number of Java guides? I'm in the process on creating one for internal use but would love to base it off existing work, either by SFDC or a colleague.

In an ideal world, MavensMate and Eclipse can use the style guide for linting, but I'm happy with simply a programmer-readable textual version.

If no one has one and is considering employing one, would anyone be interested in collaborating?


1 Answer 1


I started on this style guide months ago, made it open source. I finally got it to v0.1.

The Apex guide is based on Google's Java style guide as mentioned by Peter Knolle.

The Visualforce style guide does not yet exist.

The Salesforce admin style guide also does not yet exist.

The ant migration style guide does not exist, but I'm not sure it ought to.

Are there other aspects that I should consider?

  • 5
    Nice start. One thing I'd like to mention. SFDC being an online platform counts whitespaces. Your indentation of 2 spaces literally uses double the space if you used tabs. Over a lot of code this really adds up. Normally I'd agree over the 2 space (or other arbitrary spaces #) but not on this platform. My old company I worked for agreed that for this reason tabs is far superior and I also brought this belief into my current company. You don't have to agree but I wanted to make sure the character count was something you thought about and were aware of.
    – dphil
    Commented Nov 3, 2014 at 18:16
  • @dphil that's a great point. (I would rather pay that price in my small org, but I can see it being a problem in a larger one). Commented Nov 3, 2014 at 19:06
  • And what's to say your small org won't grow one day to become a large one? Even if not large in data, large in code. I always try to build based on the assumption that things will grow. Sort of the same reason I bulkify triggers. Sure we might only insert those records 1 at a time, but what if some day the process changes and we insert in bulk? I mean I definitely understand the reason you have for the 2 spaces, just adding a separate view on it.
    – dphil
    Commented Nov 3, 2014 at 21:12
  • 1
    @dphil I agree entirely. That's why I wantinput from folks with more than my 12 months Salesforce experience. Commented Nov 3, 2014 at 22:02
  • 1
    @smohyee How about an Admin style guide that focuses on naming conventions? Commented Jul 20, 2015 at 16:41

You must log in to answer this question.

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