Different Code Styles and VCS

Hi,

what do u think about the following problem:
The developers in one team user different code styles (blanks...).

Reformating the code on your own style touches many, many files. If two developers use the same file very often, they will get many revisions without any "relevant" changes.
There will also occur many conflicts, if the first is changing a file, while the second one just reformats that file...


What can be done to avoid that problem? (Force the other guy to use your own code style isn´t always successful ;)



11 comments
Comment actions Permalink

What we do is have a check-in trigger for our source code control system that formats the code to a common style (we use astyle).

Works like a champ.

Mike

0
Comment actions Permalink

Hmm. that sounds nice. Can u tell me some details?

0
Comment actions Permalink

Michael Kirby wrote:

What we do is have a check-in trigger for our source code control system that formats the code to a common style (we use astyle).

Works like a champ.

Mike


It's on my wish list for our environment as well!

btw, this is nice reading
http://www.softwarecraftsmen.com/blog/archives/000009.html

Edo

0
Comment actions Permalink

We use clearcase. Our trigger is as follows:

trigger type "astyle_trigger"
created 28-Sep-00.11:00:12 by 0000-Admin(0000) (root.other@merlin)
owner: root
group: other
all element trigger
pre-operation checkin
action: -execunix /apps/jas/bin/astyle --style=ansi --indent=spaces=4 --indent-classes --indent-switches $CLEARCASE_PN
action: -execwin c:\perl\site\astyle.exe --style=ansi --indent=spaces=4 --indent-classes --indent-switches %CLEARCASE_PN%
restriction: element type java_file

We install astyle on our PC's as well, so PC based checkins get it as well.

It is restricted to files of type java_file, so not everything gets run through the trigger.

Astyle itself is found at:

http://sourceforge.net/projects/astyle/

We recently changed from tabs to spaces. I don't know why I ever used tabs originally, but it was a pain in the but...avoid them.

Mike

0
Comment actions Permalink

Curious, why do you say it was a paint in the butt to use tabs? I always felt they were the more versatile of the 2 formatting methods simlpy because a developer who preferred different spacing for his tabs could change his value of how many spaces a tab represented (Some use 2, some use 4 and a few use 8). But with spaces, you are stuck with whatever the last guy used.

Clarification?

0
Comment actions Permalink

If you've ever looked at code written by someone else with different tab
settings, you'll understand. It's not so bad when the code uses tabs alone;
it really becomes a problem when a mixture of tabs and spaces are used.

Vil.

Robert Green wrote:

Curious, why do you say it was a paint in the butt to use tabs? I always felt they were the more versatile of the 2 formatting methods simlpy because a developer who preferred different spacing for his tabs could change his value of how many spaces a tab represented (Some use 2, some use 4 and a few use 8). But with spaces, you are stuck with whatever the last guy used.

Clarification?


--
Vilya Harvey
vilya.harvey@digitalsteps.com / digital steps /
(W) +44 (0)1483 469 480
(M) +44 (0)7816 678 457 http://www.digitalsteps.com/

Disclaimer

This e-mail and any attachments may be confidential and/or legally
privileged. If you have received this email and you are not a named
addressee, please inform the sender at Digital Steps Ltd by phone on
+44 (0)1483 469 480 or by reply email and then delete the email from
your system. If you are not a named addressee you must not use,
disclose, distribute, copy, print or rely on this email. Although
Digital Steps Ltd routinely screens for viruses, addressees should
check this email and any attachments for viruses. Digital Steps Ltd
makes no representation or warranty as to the absence of viruses in this
email or any attachments.

0
Comment actions Permalink

Vilya Harvey wrote:

If you've ever looked at code written by someone else with different tab
settings, you'll understand. It's not so bad when the code uses tabs
alone; it really becomes a problem when a mixture of tabs and spaces are
used.


Not generally, but when a dumb mixture of tabs and spaces are used.
IDEA's smart tabs look good independent of the tab-size settings.

Tom

0
Comment actions Permalink

Thomas Singer wrote:

Vilya Harvey wrote:

>> If you've ever looked at code written by someone else with different
>> tab settings, you'll understand. It's not so bad when the code uses
>> tabs alone; it really becomes a problem when a mixture of tabs and
>> spaces are used.


Not generally, but when a dumb mixture of tabs and spaces are used.


That's what I mean. A classic case in point is the JDK source code: looks
dreadful if you use any tab setting other than 8, because every second level
of indentation is actually four spaces.

IDEA's smart tabs look good independent of the tab-size settings.


I'm sure you're right. Unfortunately not everyone here uses IDEA, so our
coding standard mandates the use of spaces instead of tabs. That's just our
situation though; whatever works best for you...

Vil.
--
Vilya Harvey
vilya.harvey@digitalsteps.com / digital steps /
(W) +44 (0)1483 469 480
(M) +44 (0)7816 678 457 http://www.digitalsteps.com/

Disclaimer

This e-mail and any attachments may be confidential and/or legally
privileged. If you have received this email and you are not a named
addressee, please inform the sender at Digital Steps Ltd by phone on
+44 (0)1483 469 480 or by reply email and then delete the email from
your system. If you are not a named addressee you must not use,
disclose, distribute, copy, print or rely on this email. Although
Digital Steps Ltd routinely screens for viruses, addressees should
check this email and any attachments for viruses. Digital Steps Ltd
makes no representation or warranty as to the absence of viruses in this
email or any attachments.

0
Comment actions Permalink

Curious, why do you say it was a paint in the butt to
use tabs? I always felt they were the more versatile
of the 2 formatting methods simlpy because a
developer who preferred different spacing for his
tabs could change his value of how many spaces a tab
represented (Some use 2, some use 4 and a few use 8).
But with spaces, you are stuck with whatever the last
guy used.

Clarification?



You can't print with them and different programs interpret them differently by default (vi/emacs/notepad/IDEA). We also had issues with some editors would replace spaces with tabs in ways that didn't match our 4 space/tab standard. When astyle ran, if those tabs were in commented areas, the comments would go out of alignment.

With spaces, astyle will generally do the right thing (although errant editors that insist on inserting 8 space tabs, will still cause the occasional problem.

For us, it is important that we be consistent across versions in our configuration management system.

Mike

0
Comment actions Permalink

FYI, you can find an argument against tabs at
<http://www.jwz.org/doc/tabs-vs-spaces.html>.

Kendall

"Robert Green" <no_mail@jetbrains.com> wrote in message
news:19088881.1059966796863.JavaMail.javamailuser@localhost...

Curious, why do you say it was a paint in the butt to use tabs? I always

felt they were the more versatile of the 2 formatting methods simlpy because
a developer who preferred different spacing for his tabs could change his
value of how many spaces a tab represented (Some use 2, some use 4 and a few
use 8). But with spaces, you are stuck with whatever the last guy used.
>

Clarification?



0

Please sign in to leave a comment.