Standards Document

I am writing a coding standards document for a team of about 15 developers with a project load of 10 to 15 projects per year. Among the other sections (which I can post here when I get to them), I am writing a section on code formatting. So for starters, I think it's reasonable that for some reason we set some basic, consistent code formatting / notation standards.

I looked at about 10 projects written over the past 3 years from this team, and I obviously find a fairly wide range of styles. Contractors come and go, and sometimes even double the size of the team.

I am looking for some suggestions for code formatting and naming standards that have really paid off ... but it can also be really justified. I think that consistency and common patterns are of great importance for providing more convenient code maintenance ... but are there other things that I should consider when defining the specified standards?

  • How do you group parentheses? Do you follow the same brackets when working with classes, methods, try catch block, switch statements, if else blocks, etc.

  • Are you aligning fields in a column? Do you mark / prefix private variables with underscores? Do you follow any naming conventions to make it easier to find information in a file? How do you order your class members?

What about suggestions for namespaces, packaging, or organization source codes / standards? I start with something like:

<com|org|...>.<company>.<app>.<layer>.<function>.ClassName

I am curious to find out if there are other, more acceptable, practices than what I'm used to - before I dare to dictate these standards. References to standards already published on the Internet will also be good - although I have already done this a bit.

+5
source share
4 answers

First, find an automatic code formatter that works with your language. Reason: No matter what the document says, people inevitably break the rules. It is much easier to run code through a formatter than using nit-pick in a code review.

(, Java, #), , , . Sun ; .

, , , , . any - .

+3

, :

. , , .

if(...)
{

}

/ . , .

, , if... elseif... else, , . if .

, , , , .

while(stillwaiting())
{
   ;
}

typedefs, , .. . , , . , ..

, .

-Adam

+3

.

10-12, perl. "perltidy- ". perltidy, , . , .

Google, , , , . , , ; .

, !

+2

This obviously varies with languages ​​and technologies. By the look of your example namespace, I'm going to guess java, in which case http://java.sun.com/docs/codeconv/ is a really good place to start. You can also look at something like the standard maven directory structure, which will make all your projects look alike.

+1
source

All Articles