glob2-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[glob2-devel] Code Format


From: Leo Wandersleb
Subject: [glob2-devel] Code Format
Date: Thu, 04 Mar 2010 03:17:00 +0100
User-agent: Thunderbird 2.0.0.23 (X11/20090817)

Hi all,

while working with hudson [1] I once more got frustrated about ever differing
code styles.
Modern IDEs allow to auto-format on save. In Eclipse I basically don't care
about spaces or anything when coding Java. When pressing "save" all formatting
is done for me. Consistently for all my team members.
It helps big deal on speed as formatting is not an issue any more.
To get there it has been proven best to not discuss about every detail but to
use some well established formatting as this should be easiest to get synced
across IDEs. Are there any objections to formatting all the code according to
either of the K&R or BSD (see below)? If no I would do so.

Regards,

Leo Wandersleb



K&R (my favourite. most compact.)
> /*
>  * A sample source file for the code formatter preview
>  */
> #include <math.h>
> 
> class Point {
> public:
>       Point(double xc, double yc) :
>               x(xc), y(yc) {
>       }
>       double distance(const Point& other) const;
> 
>       double x;
>       double y;
> };
> 
> double Point::distance(const Point& other) const {
>       double dx = x - other.x;
>       double dy = y - other.y;
>       return sqrt(dx * dx + dy * dy);
> }

BSD/Allman (maybe closest to what glob2 mostly follows.)
> /*
>  * A sample source file for the code formatter preview
>  */
> #include <math.h>
> 
> class Point
> {
> public:
>       Point(double xc, double yc) :
>               x(xc), y(yc)
>       {
>       }
>       double distance(const Point& other) const;
> 
>       double x;
>       double y;
> };
> 
> double Point::distance(const Point& other) const
> {
>       double dx = x - other.x;
>       double dy = y - other.y;
>       return sqrt(dx * dx + dy * dy);
> }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]