Fun to Program – Coding style

Date: 2013/08/24 (initial publish), 2021/08/02 (last update)

Source: en/fun2-00024.md

Previous Post Top Next Post

TOC

This was originally written and created around 2013 and may require to be updated. (2021)

Coding style

Follow the existing practice for the source.

Osamu’s preference at this moment is as follows:

C coding style

There are 2 major practices for the C coding style.

There are many variants in use.

Here are summary of the K&R styles.

See also http://www.teamten.com/lawrence/style/notes.html[Notes on Programming Practices] by Lawrence Kesteloot for some detail C style examples.

Naming conventions

Basic naming convention used in C is:

For many object oriented languages, CamelCase naming convention is introduced to differentiate between class name and class instance name.

The Hungarian Notation especially Systems Hungarian which encodes the physical data type into prefix is deplored. There are http://www.joelonsoftware.com/articles/Wrong.html[some defense to Apps Hungarian which encodes the logical data type into prefix].

Reformat

Reformat source with indent:

$ indent -linux foo.c

Document style

GNOME

There are four golden rules:

See more at GNOME Documentation Style Guide and GDP Documentation Guidelines .

SUSE

See Documentation Style Guide .

GNU

See A Style Guide for GNU Documentation (PDF) .

EC

European Commission recommends in How to write clearly (PDF) (HTML) as:

Wikipedia

See Wikipedia: List of style guides .

Previous Post Top Next Post