Consensus on the kdelibs coding style
Chani
chanika at gmail.com
Sat Jul 5 20:02:42 BST 2008
>
> Just for reference the rationale for the two rules:
> - When you have if blocks with one-liners which don't have brackets, it can
> in some cases lead to wrong code, if somebody adds an indented line of
> code, but no brackets. It looks right, but us wrong. Additionally when
> moving around code, you might end with dangling brackets, if some code
> blocks use them and some others don't.
when I first saw this in kdelibs style, I thought it was stupid - but after
working with it for a while, I understand and appreciate it. the more people
you have working on the code, the more important clarity becomes.
besides, inconsistent style may not bother lubos, but it's like nails on a
chalkboard to me.
> - 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.
personally I think all arguments about where to put the { are rather silly...
but OTBS feels best to me.
I also prefer tabs to spaces, but I can see I have no hope of getting that
here :)
>
> 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.
>
> So I don't think there is much point in discussing the style once again. We
> have a style on techbase, a lot of code follows that, so let's just use
> that and put our energy on something which is more fun and productive.
I agree. we have a style, it's not awful, there's a .vim file that allows me
to follow it effortlessly... I'm having a lot of trouble caring about the
history here. a style probably shouldn't have been picked without proper
discussion, but what's done is done. I just want to keep using what works.
--
This message brought to you by evyl bananas, and the number 3.
www.chani3.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20080705/025d9c66/attachment.sig>
More information about the kde-core-devel
mailing list