Consensus on the kdelibs coding style

Ingo Klöcker kloecker at
Mon Jul 7 22:17:18 BST 2008

On Saturday 05 July 2008, Cornelius Schumacher wrote:
> On Saturday 05 July 2008 15:41:23 Lubos Lunak wrote:
> > ===== Coding style proposal =====
> (...)
> So in a slightly shortened version you want to change the coding
> style which is on techbase in two aspects:
> - Putting the opening brackets of code block to an own line (because
> your personal view and that of the Wikipedia author is that it's more
> readable)
> Sounds like a true coding style discussion ;-)
> Just for reference the rationale for the two rules:
> - The opening bracket on an extra line violates what McConnell calls
> the Fundamental Theorem of Formatting (It says that good visual
> layout shows the logical structure of the code). The bracket
> logically belongs to the control statement which opens the block.
> Putting it in the body, but not indenting it puts it at a place where
> it neither belongs to the control structure nor to the body. That can
> be perceived as misleading. Additionally this style consumes more
> vertical space, so that you can see less code on your screen at once,
> which can make it harder to read the code.
> That said, there are no clear arguments why to use one or the other
> variant of the style. As far as I know, all studies which research
> this question show, that these variants of coding style don't affect
> readability.

A slight variation of Thiago's example:

int main(int argc, char **argv)
    if (argc >=2 &&
        strcmp(argv[1], "--help")) {
        return 0;

If that's not a clear argument for putting the opening braces of a code 
block to a line of its own (which is what Thiago actually did in the 
original example) then I don't know what a clear argument is. But if 
you agree that in this case the opening brace should be placed on a 
line of its own then for consistency and simplicity of the coding style 
guidelines you should agree to make this a general rule.

Anyway, instead of sweating the small stuff, it would be way more 
helpful if we recommended all of KDE's contributors to read and follow 
the (almost exclusively) indisputable guidelines and best practices 
presented in H. Sutter's and A. Alexandrescu's "C++ Coding Standards" 

Incidentally rule no. 0 presented ibid. reads:

  Don’t sweat the small stuff. (Or: Know what not to standardize.)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part.
URL: <>

More information about the kde-core-devel mailing list