[morphia] side question on code formatting rules

2 views
Skip to first unread message

Uwe Schäfer

unread,
May 20, 2010, 2:48:23 AM5/20/10
to mor...@googlegroups.com
hi

do you happen to have a code formatting definition file for ecplise that
you want used in the code?

it gets a little burdonsome to keep my eclipse from changing the
formatting while still maintaining proper indentation etc.

cu uwe

Ólafur Gauti Guðmundsson

unread,
May 20, 2010, 6:11:04 AM5/20/10
to mor...@googlegroups.com
Hi,
I use the "standard" java coding convention rules, as implemented by my IDE (Netbeans). I also always use curly braces for conditional/for/while/etc statements, and never put them on a single line. However, I think Scott has a more "compact" coding style ;)

But I agree we need a common formatting definition.

Regards,
OGG

2010/5/20 Uwe Schäfer <u...@thomas-daily.de>

Scott Hernandez

unread,
May 20, 2010, 11:30:25 AM5/20/10
to mor...@googlegroups.com
I have a small screen and try to keep vertical dead-space to a
minimum, within reason (sometimes putting if statements on a single
line without braces, or by using ternary operations). In eclipse it is
easy enough to specify formatting rules per project. I'm sure netbeans
can do the same. I work in a few projects with dissimilar formatting
styles.

I can export my eclipse formatting rules and keep them checked into
svn if that would help. As Oli said as well, I'm working from the
eclipse defaults for the most part.

2010/5/20 Ólafur Gauti Guðmundsson <oli....@gmail.com>:

Uwe Schäfer

unread,
May 20, 2010, 12:15:05 PM5/20/10
to mor...@googlegroups.com
Scott Hernandez schrieb:

> I can export my eclipse formatting rules and keep them checked into
> svn if that would help.

yes it would help (at least me, using eclipse as well) - please do so. :)

cu uwe

Scott Hernandez

unread,
May 20, 2010, 1:24:11 PM5/20/10
to mor...@googlegroups.com
I checked in my code formatting profile (as exported from eclipse 3.5).

How do you feel about column length and line wrapping? I find 80
characters a little short; I have mine set at 120.

2010/5/20 Uwe Schäfer <u...@thomas-daily.de>:

Uwe Schäfer

unread,
May 20, 2010, 1:30:29 PM5/20/10
to mor...@googlegroups.com
Scott Hernandez schrieb:
> I checked in my code formatting profile (as exported from eclipse 3.5).

thanks.

> How do you feel about column length and line wrapping? I find 80
> characters a little short; I have mine set at 120.

i couldn´t care less. working on 2 screens anyway.
in our shop, we´re using a completely different formatting style, that
probably wouldn´t fit yours.

it´s just about not messing up formatting accidentally and then having a
hard time merging that ;)

cu uwe

Scott Hernandez

unread,
May 20, 2010, 1:37:41 PM5/20/10
to mor...@googlegroups.com
I find the most annoying part when someone reformat a file and the
diff show everything, not just the changes as changed. Of course, one
way to deal with this is to just reformat the whole document before
checkin, and on checkout.

I've worked in places where you were free to use whatever format/style
you wanted and checkin/editor settings took care of reformatting for
you. It is a little more complicated, but it leads to less problems
between developers (until you print out some code and discuss it
around the table; then everyone wants their own printout).

There is no perfect way.

In eclipse you can also setup save rules to reformat a document; there
have been issues with that and the svn/auto-save plugins, but I think
they are resolved now.

2010/5/20 Uwe Schäfer <u...@thomas-daily.de>:

Uwe Schäfer

unread,
May 20, 2010, 1:53:22 PM5/20/10
to mor...@googlegroups.com
Scott Hernandez schrieb:

> In eclipse you can also setup save rules to reformat a document; there
> have been issues with that and the svn/auto-save plugins, but I think
> they are resolved now.

you could also let eclipse reformat only changed lines, but that gets
spooky once you copy a block of code (which is then handled as
changed/thus reformatted)

for all to following the same formatting and make eclipse enforce it is
the best solution i have experienced to avoid noise in diffs.

cu uwe

Scott Hernandez

unread,
May 20, 2010, 2:31:02 PM5/20/10
to mor...@googlegroups.com
2010/5/20 Uwe Schäfer <u...@thomas-daily.de>:
Yep, but someone has to reformat all the code to standard before it helps :)

Let's come back to this after Oli has time to put in his two cents.

>
> cu uwe
>

Uwe Schäfer

unread,
May 20, 2010, 2:36:05 PM5/20/10
to mor...@googlegroups.com
Am 20.05.2010 20:31, schrieb Scott Hernandez:

> Yep, but someone has to reformat all the code to standard before it helps :)

uh, ok. i thought the code was already in line with that def. :)
whatever, i´m fine with anything you can agree on.

thanks.

Scott Hernandez

unread,
May 20, 2010, 2:46:00 PM5/20/10
to mor...@googlegroups.com
2010/5/20 Uwe Schäfer <u...@thomas-daily.de>:
I just ran the code formatter on a few files and there were lots of
whitespace and other changes. The code formatter settings just for
insert starter code (method sigs, for/switch statements, refactoring),
you still edit it after that. I don't use save actions to reformat
documents.

> thanks.
>
Reply all
Reply to author
Forward
0 new messages