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?

Remember to think about constructs that are unique to Apex compared to e.g. Java.
– Keith CJul 17 '14 at 23:14

2

As far as collaboration, I'd be interested if you don't find a suitable version to work from.
– sfdcfoxJul 18 '14 at 0:09

7

I couldn't find one and created one for my company internally, but can't share. :( I started with Google's Java Style Guide as a base for Apex and tweaked it until satisfied.
– Peter KnolleJul 18 '14 at 3:30

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.
– dphilNov 3 '14 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).
– Charles KoppelmanNov 3 '14 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.
– dphilNov 3 '14 at 21:12