For getting a consistent reading through all the sources, it is important to keep the coding style the same, all over the aRts source. Please, even if you just write a module, try to write/format your source accordingly, as it will make it easier for different people to maintain the source tree, and easier to copy pieces of from one source to another.
Qt™/Java™ style. That means capitalization on word breaks, and first letter always without capitalization; no underscores.
This means for instance:
createStructureDesc() updateWidget(); start();
Class members are not capitalized, such as menubar or button.
When there are accessing functions, the standard should be the MCOP
way, that is, when having an long member foo
, which
shouldn't be visible directly, you create:
foo(long new_value); long foo();
functions to get and set the value. In that case, the real value of
foo
should be stored in
_foo.
All classes should be wordwise capitalized, that means
ModuleView
,
SynthModule
. All classes that belong to the
libraries should use the aRts namespace, like
Arts::Soundserver
.
The implementations of MCOP classes should get called
Class_impl
, such as
SoundServer_impl
.
Parameters are always uncapitalized.
Local variables are always uncapitalized, and may have names like
i
, p
, x
, etc.
where appropriate.
One tab is as long as 4 spaces.
You normally don't need to use spaces in expressions. You can however use them between operator and their operands. However, if you put a space before an operator (i.e. +), you also need to put a space after the operator. The only exception to this are list-like expressions (with ,), where you should only put a space after the ",", but not before. It's okay to omit the space here, too.
The following examples demonstrate good use of spaces:
{ int a,b; int c, d, e; int f = 4; a=b=c=d+e+f; a = b = c = d + e + f; if(a == 4) { a = b = c = (d+e)/2; } while(b<3) c--; arts_debug("%d\n", c); }
The following examples demonstrate how not to use spaces. For function calls, after if, while, for, switch and so on, no space is being written.
{ // BAD: if you write a list, write spaces only after the "," int a , b , c , d , e , f; // BAD: non-symmetric use of spaces for = operator a= 5; // BAD: if is considered a function, and isn't followed by a space if (a == 5) { } // BAD: don't write a space after while while (a--) b++; // BAD: functions names are not followed by a space arts_debug ("%d\n", c); // BAD: neither are member names Arts::Object o = Arts::Object::null (); }
Source files should have no capitalization in the name. They should have
the name of the class when they implement a single class. Their
extension is .cc
if they refer to
Qt™/GUI independent code, and .cpp
if they refer to Qt™/GUI dependant
code. Implementation files for interfaces should be called
, if Foo was the
name of the interface.
foo
_impl
IDL files should be called in a descriptive way for the collection of interfaces they contain, also all lower case. Especially it is not good to call an IDL file like the class itself, as the .mcopclass trader and type info entries will collide, then.
Would you like to make a comment or contribute an update to this page?
Send feedback to the KDE Docs Team