Latest

Archive

Community news

C++

Communities and Content

Databases

Editorials

Emacs

General

HTML

Java

Notices

PHP

XML

Apache

C++

Database

General

HTML

Java

Javascript

Linux

Object oriented programming

Open source

Perl

PHP

Python

Ruby

SOAP

XML

Suggest a link

Advertise on zez

Contribute

Contact us

About zez


Coding Standards - Part 2 - Basic conventions




Parentheses, brackets and comma


Use a space after every comma. Use a space after a begin parenthesis, and a space before an end parenthesis. Do not use such spaces for square brackets. Use one, and only one space between each type. Put pointer * and reference & signs adjacent to the variable they belong to.

Use empty lines to group variables and codelines that logically belongs together. Variable names that are grouped this way must be on the same column. Empty lines must be empty, containing no TABs or spaces.

If you are unsure of the execution order of an expression, use more than the minimum required number of parentheses and remove them when it becomes more clear.

If statements and while loops


Nested if statements must use brackets {}. If you have many consecutive if and else if statements, consider using case statements instead, or redesign using a more object oriented approach.

If statements and while loops can only execute boolean expressions, never assign or change any data.

The next issue of this article will be a bit longer and more advanced, as I'll advance to topics such as naming conventions, functions, classes and namespaces.


<< Previous page | 1 | < 2 > | Printer-friendly page |

Comment List


Topic: Author:
Time:
Coding Standards Leone Viru 16.12.2003 11:31

I am truly impressed and happy to feel that my "own" personal coding style is same. Me as a man who wants to see system and order in everywhere I used pure and clear code since the beginning. Because making not ordered code will end up sooner or later with kahos.


Coding standards !! Well wake up... and take a look at "man Lars Hesdorf 03.12.2000 12:14

Basically fine with an article Coding standards. But when you hare argued about why to preferably use one style instead of an another then please also give the arguments for the "indent" program to us to enforce to coding style.




Forgot your password?

Register a new user

Results

Polls