* if you're not interested in Hugin's development, you can stop reading now*

Hello Hugin developers,

I've been looking at our source code and I find that it can use some 
consistency / clean up. The current status is historically grown - I am 
not sure every contributor has seen Pablo's notes [0] and I think our 
coding style belongs on the web, maybe on a wiki page?

I would like to reach a consensus amongst the developers of what coding 
style we want. The consensus coding style should become a very strong 
recommendation for new code (I don't feel like policing volunteers / 
mandating it, but if we start to see unreadable code in commits we'll 
have to discuss it because this is critical for the project's long term 
viability); and when developers go over existing code, they can 
optionally make it more readable for themselves and for those coming 
after them.

Do we want a loose coding style guideline like [1]? or a strict one like 
[2]? I tend for a loose - define a necessary minimum and let the good 
common sense of each individual contributor prevail.

Below are different points for discussion. If I have forgot one that you 
deem important in coding style, please add it. For every point there are 
a few alternatives. I have surely missed on alternatives and variations, 
so if you think that more should be added, do it.

I kindly ask you to express your opinion to each and every single point 
as a contribution to the discussion. After most committers have 
expressed their opinion I will summarize the choices and propose a 
coding style for adoption.


1. NAMING CONVENTIONS

1.1. PRIVATE VARIABLES

all private variables should have a prefix. Many (but not all) private 
variables are currently prefixed with m_ and I suggest to retain this 
style consistently across the codebase.

1.2. VARIABLE NAMES

some variables are named with the CamelCase convention - capitalizing 
the beginning of the word. Other use the word_separated_by_underscore 
convention. Are there other conventions? Which one do you favor?

variable names should be clear and descriptive. no contractions, maybe 
with a few listed exception, e.g. Pano instead of Panorama. Any more 
exceptions?

1.3. FUNCTION NAMES

should functions follow the same conventions as variables? or a 
different one?

function names should be descriptive. no contractions, maybe with a few 
listed exception, e.g. Pano instead of Panorama. Any more exceptions?


2. COMMENTS

2.1. DOCUMENTATION (copied verbatim from Pablo)

document your code (or the code you are reading and understanding) with 
doxygen (http://www.doxygen.org). Doxygen is a useful tool and can also 
be used to create other documentation that just class interface 
descriptions. It works by prefixing the function prototypes with a 
special comment. Pablo usually puts the documentation in the header files.

       The basic usage is very javadoc like:

       /** One sentence class description
        *
        *  more detailed description
        *
        *  @todo pet the cat more often
        *  @bug  might scratch if annoyed
        */
       class Cat
       {
       public:
           /** hunt food
            *
            *  @param prey type of animals that we should hunt
            *  @return true if the cat is sated
            */
           bool HuntFood(Prey prey);

       }

2.2. WORK IN PROGRESS

if something needs work, put a // FIXME or // TODO comment so that a 
grep will reveal places that needs attention. Gedit automatically 
highlights TODO and FIXME.


3. SPACING AND INDENTATION

3.1. BRACES

there are many different indent styles [3]. I am personally used to 1TBS 
[4] (like the Linux Kernel), but I recently heard good arguments to 
adopt Allman style [5], which puts the brace associated with a control 
statement or a function on the next line, indented to the same level as 
the control statement. I am ready to go Allman. Or maybe you want to 
suggest other alternatives? Which one do you prefer?

3.2. TABULATORS

use spaces instead of tabulators (to maintain consistency across 
editors). use four spaces for one indentation. or are there other 
preferences?

3.3. SPACES

I would not go into that much detail. or maybe we should adopt/adapt a 
strict coding guide like [2]?

3.4. LINE ENDS

Unix/Linux line ending (Windows and OSX users have to adapt)


4. COMMITTS

It is tempting to clean up old code while fixing bugs or adding new 
code. Please don't - it makes the committ (diff!) much more difficult to 
read / understand.

Keep style clean up committs separated and mention them as such in the 
log message.

I think that's about it, but I may be missing something. time to hit the 
pillow.

Yuv



[0] 
<http://hugin.svn.sourceforge.net/viewvc/hugin/hugin/trunk/src/dox/mainpage.dox?view=markup>
[1] 
<http://developer.gnome.org/doc/guides/programming-guidelines/code-style.html>
[2] 
<http://www.blender.org/documentation/intranet/conventions/codingstyleguide.html>
[3] <http://en.wikipedia.org/wiki/Indent_style>
[4] <http://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS>
[5] 
<http://en.wikipedia.org/wiki/Indent_style#Allman_style_.28bsd_in_Emacs.29>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"hugin and other free panoramic software" group.
A list of frequently asked questions is available at: 
http://wiki.panotools.org/Hugin_FAQ
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/hugin-ptx
-~----------~----~----~----~------~----~------~--~---

Reply via email to