Documenting Coding Conventions

371 views
Skip to first unread message

Richard Cox

unread,
Nov 24, 2009, 1:27:44 PM11/24/09
to Noda Time at Google Groups
I've made a brief start at
http://code.google.com/p/noda-time/wiki/CodingConventions

(From memory of discussions here.)


--
Richard

The Configurator

unread,
Nov 24, 2009, 6:31:32 PM11/24/09
to noda...@googlegroups.com
Regarding coding conventions, working with multiple C# formatting configurations seems to be broken in VS 2010. Is it just me?

Also, I wanted to ask, does anyone know if it is possible to have a formatter automatically change tabs to spaces on commit? I'd really prefer while editing that tabs be tabs, this is driving me nuts!

James Curran

unread,
Nov 24, 2009, 9:15:55 PM11/24/09
to noda...@googlegroups.com
On Tue, Nov 24, 2009 at 6:31 PM, The Configurator
<config...@gmail.com> wrote:
> Also, I wanted to ask, does anyone know if it is possible to have a
> formatter automatically change tabs to spaces on commit? I'd really prefer
> while editing that tabs be tabs, this is driving me nuts!


If you like tabs, why change them at all? Aligning things in
columns is *precisely* the reason the Good Lord gave a a tab key inthe
first place.


--
Truth,
James

James Keesey

unread,
Nov 24, 2009, 11:02:03 PM11/24/09
to Noda Time


On Nov 24, 6:15 pm, James Curran <james.cur...@gmail.com> wrote:
> On Tue, Nov 24, 2009 at 6:31 PM, The Configurator
>
> <configura...@gmail.com> wrote:
> > Also, I wanted to ask, does anyone know if it is possible to have a
> > formatter automatically change tabs to spaces on commit? I'd really prefer
> > while editing that tabs be tabs, this is driving me nuts!
>
>    If you like tabs, why change them at all?   Aligning things in
> columns is *precisely* the reason the Good Lord gave a a tab key inthe
> first place.
>
> --
> Truth,
>     James

Except how big is a tab? One tab per indentation or a tab at every 8
characters with spaces filling in the rest? With spaces it's always
right.

James K.

Jon Skeet

unread,
Nov 25, 2009, 1:49:21 AM11/25/09
to noda...@googlegroups.com
2009/11/25 James Keesey <james....@gmail.com>
>    If you like tabs, why change them at all?   Aligning things in
> columns is *precisely* the reason the Good Lord gave a a tab key inthe
> first place.

Except how big is a tab? One tab per indentation or a tab at every 8
characters with spaces filling in the rest? With spaces it's always
right.

Indeed. If I were to be dictatorial about one issue, it would be this :) Spaces please.

Jon

The Configurator

unread,
Nov 25, 2009, 2:34:02 AM11/25/09
to noda...@googlegroups.com
Who in their right mind uses 8 character tabs with 4 character indentation? That doesn't make any sense...

The good point about tabs and indentation is that if I like 4 characters indentation and a co-worker likes 3, we can (and did) coexist peacefully quite well. Simple change settings to match your preference and voila - code file is the same, but looks however you like it. Of course, that could only work when tabs are mandatory, which they were where I did this.

Philippe Vlérick

unread,
Nov 25, 2009, 6:19:03 AM11/25/09
to noda-time
Religious debate ahead :)

I'm on the tab side. When you use spaces, you force everyone to see the code as you like it. I don't see any advantage of using spaces instead of tabs.

However, I'm not rigid on practices, even if I don't like them. If we decide spaces, I'll use spaces. There's an option to do that in VS anyway.
--
Philippe Vlérick

Philippe Vlérick

unread,
Nov 25, 2009, 6:19:23 AM11/25/09
to noda-time
Religious debate ahead :)

I'm on the tab side. When you use spaces, you force everyone to see the code as you like it. I don't see any advantage of using spaces instead of tabs.

However, I'm not rigid on practices, even if I don't like them. If we deicide spaces, I4

On Wed, Nov 25, 2009 at 8:34 AM, The Configurator <config...@gmail.com> wrote:



--
Philippe Vlérick

Richard Cox

unread,
Nov 25, 2009, 6:35:43 AM11/25/09
to noda...@googlegroups.com
Philippe Vlérick wrote:
> Religious debate ahead :)
>
> I'm on the tab side. When you use spaces, you force everyone to see the
> code as */you/* like it. I don't see any advantage of using spaces
> instead of tabs.

The advantage is that it makes the code independent of some more editor
settings (and particularly other tools -- e.g. less, diff -- useful for
a quick view of the code without spinning up an IDE).

This is why I switched to spaces a few years ago, and not missed anything.

> However, I'm not rigid on practices, even if I don't like them. If
> we decide spaces, I'll use spaces. There's an option to do that in VS
> anyway.

There are also options to convert tabs to spaces and visa versa in VS.

--
Richard

Jon Skeet

unread,
Nov 25, 2009, 6:35:06 AM11/25/09
to noda...@googlegroups.com
As you say, Visual Studio can let you reformat anyway. One advantage of spaces over tabs: it's the Visual Studio default as far as I'm aware. If we were going to start changing things like that, I'd be advocating two space block indentation with four space line continuation. (Except that I'm not sure VS has separate options for that. Doh.)

But yes, it's a religious issue. I've only ever seen problems with tabs (particularly when code is viewed in settings other than the IDE), and no real benefits.

It would be quite nice to have a "reformat to standard <x> on commit; reformat to standard <y> on update" option somewhere, so everyone gets to see it the way they want, but it does mean completely trusting the reformatter for everything...

Jon

2009/11/25 Philippe Vlérick <pvle...@gmail.com>

Richard Cox

unread,
Nov 25, 2009, 6:42:34 AM11/25/09
to noda...@googlegroups.com
The Configurator wrote:
> Regarding coding conventions, working with multiple C# formatting
> configurations seems to be broken in VS 2010. Is it just me?

It seems to work here OK, importing a settings file containing default
formatting, formatting the document, importing settings for correct^h my
preferred and formatting document again works (once I select the right
file to import :-)).

> Also, I wanted to ask, does anyone know if it is possible to have a
> formatter automatically change tabs to spaces on commit? I'd really
> prefer while editing that tabs be tabs, this is driving me nuts!

I don't think so, a macro should be able to combine the operations
easily enough.

--
Richard

Philippe Vlérick

unread,
Nov 25, 2009, 7:12:44 AM11/25/09
to noda-time
All right, I'll be happy with spaces.

Beside, the fact that it's VS default out trumps everything else :)
--
Philippe Vlérick

NickLarsen

unread,
Nov 25, 2009, 11:04:43 AM11/25/09
to Noda Time
The most important issue is just that it all looks the same in the end
and that you shouldn't be able to tell who authored the type based on
the format styling alone.

That being said, I am going to argue in favor of what looks as
intended when downloaded and opened in the environment we expect this
to be opened in the most. In this case thats Visual Studio, so the
formatting needs to all conform to the defaults of Visual Studio.

I completely understand people wanting to change the formatting for
how they feel it should be, we all do it, but I can't stand it when I
sit down to play a video game after someone has changed the default
controls around. Naturally you can set it up however you want it when
you're working with it, but please return to default for the next
user.

On Nov 25, 6:35 am, Jon Skeet <sk...@pobox.com> wrote:
> As you say, Visual Studio can let you reformat anyway. One advantage of
> spaces over tabs: it's the Visual Studio default as far as I'm aware. If we
> were going to start changing things like that, I'd be advocating two space
> block indentation with four space line continuation. (Except that I'm not
> sure VS has separate options for that. Doh.)
>
> But yes, it's a religious issue. I've only *ever* seen problems with tabs
> (particularly when code is viewed in settings other than the IDE), and no
> real benefits.
>
> It would be quite nice to have a "reformat to standard <x> on commit;
> reformat to standard <y> on update" option somewhere, so everyone gets to
> see it the way they want, but it does mean completely trusting the
> reformatter for everything...
>
> Jon
>
> 2009/11/25 Philippe Vlérick <pvler...@gmail.com>
>
>
>
> > Religious debate ahead :)
>
> > I'm on the tab side. When you use spaces, you force everyone to see the
> > code as *you* like it. I don't see any advantage of using spaces instead
> > of tabs.
>
> > However, I'm not rigid on practices, even if I don't like them. If
> > we decide spaces, I'll use spaces. There's an option to do that in VS
> > anyway.
>
> > On Wed, Nov 25, 2009 at 8:34 AM, The Configurator <configura...@gmail.com>wrote:
>
> >> Who in their right mind uses 8 character tabs with 4 character
> >> indentation? That doesn't make any sense...
>
> >> The good point about tabs and indentation is that if I like 4 characters
> >> indentation and a co-worker likes 3, we can (and did) coexist peacefully
> >> quite well. Simple change settings to match your preference and voila - code
> >> file is the same, but looks however you like it. Of course, that could only
> >> work when tabs are mandatory, which they were where I did this.
>
> >> On Wed, Nov 25, 2009 at 7:49 AM, Jon Skeet <sk...@pobox.com> wrote:
>
> >>> 2009/11/25 James Keesey <james.kee...@gmail.com>
Reply all
Reply to author
Forward
0 new messages