| 1 |
X11::GUITest ($Id: CodingStyle 203 2011-05-15 02:03:11Z ctrondlp $) |
| 2 |
|
| 3 |
This is a short list of coding style guidelines to be used when |
| 4 |
developing for this project. |
| 5 |
-------------------------------------------------------------------- |
| 6 |
|
| 7 |
General: |
| 8 |
- Utilize language idioms for aspects not covered below. |
| 9 |
- Be consistent. |
| 10 |
- Write the code for people first, computers second. |
| 11 |
- If you are just adding enhancements to an existing |
| 12 |
module and not rewriting it, you should maintain the |
| 13 |
existing coding styles that are in place. |
| 14 |
|
| 15 |
Indentation: |
| 16 |
- 4 character indents |
| 17 |
|
| 18 |
Braces/Spacing: |
| 19 |
|
| 20 |
int func(void) |
| 21 |
{ |
| 22 |
} |
| 23 |
|
| 24 |
if (var) { |
| 25 |
printf("Hello\n"); |
| 26 |
} |
| 27 |
|
| 28 |
while (true) { |
| 29 |
} |
| 30 |
|
| 31 |
Variables: |
| 32 |
- Descriptive names for globals or ones that are file scoped. Mixed |
| 33 |
case is also prefered for these. |
| 34 |
- Shorter names can be used for locals. |
| 35 |
- Use static and const when appropriate. |
| 36 |
- Perl variables should be scoped appropriately. |
| 37 |
|
| 38 |
Functions/Subroutines: |
| 39 |
- Utilize mixed case, first character of each word capitalized |
| 40 |
- Noun, Verb, etc. ordering of function names should be consistent |
| 41 |
(i.e., GetThis, SetThat) |
| 42 |
|
| 43 |
Commenting: |
| 44 |
- Don't try to explain HOW your code works, rather explain WHY it is |
| 45 |
doing what it does. |
| 46 |
- And if you have to explain a lot about your code, consider rewriting |
| 47 |
your code to be easier to follow. |
| 48 |
|
| 49 |
-------------------------------------------------------------------- |