[Mono-list] Class Library coding standards

John Barnette jbarn@httcb.net
Thu, 19 Jul 2001 00:40:28 -0600


> Given that it's impossible to get developers to agree on a
> universal coding
> standard, the only approach that I find that reasonably comes close to
> keeping things consistent is to follow the standards of the file
> you happen
> to be editing. We're all capable of doing this. If we add some code in a
> style that's different than the code around it, it will look funny to our
> brains--even if the surrounding code isn't our own personal
> style. So we can
> either reformat the entire file or get over it.

Strongly agree.  The benefits of having all the code in a repository
*formatted* in a certain way (as opposed to consistent variable naming
conventions, etc.) definitely exist, though.

An approach I've used with great success before is linking a source code
beautifier to CVS commits.  That way, any time a source file is added to the
repository, it's formatted consistently.

Anybody know of a freely-available source beautifier for C#?


~ j.



> > -----Original Message-----
> > From: mono-list-admin@ximian.com [mailto:mono-list-admin@ximian.com]On
> > Behalf Of Sean MacIsaac
> > Sent: Wednesday, July 18, 2001 12:45 PM
> > To: mono-list@ximian.com
> > Subject: [Mono-list] Class Library coding standards
> >
> >
> > Hello,
> >
> > First of all, thanks to everyone who has submitted code.  Things are
> > coming along very nicely.  Miguel and I are soon going to figure out
> > what classes we'll need to get the compiler going so that we can put
> > priority into them (and move the whole tool chain to Linux!)
> >
> > I'd like to throw out the coding standards we'd like to have in the
> > class libraries.  There is still some room to maneuver within these
> > guidelines.  Given that, please follow the style already in a file if
> > you edit it.
> >
> > * We'd like to see 8 space tabs.  If you leave the tab character, that
> > is also fine.
> >
> > * The opening brace following a namespace, class, struct, enum, property
> > or flow control unit should be at the end of the declaration line.
> >
> > * The opening brace for a function should be on the line following the
> > function.
> >
> > * Please use white space around operators and a space between function
> > names and their parameters.
> >
> > Example:
> >
> > namepace CIR {
> >         public class BoolLiteral : Literal {
> >                 bool val;
> >
> >                 public BoolLiteral (bool val)
> >                 {
> >                         this.val = val;
> >                 }
> >
> >                 override public string AsString ()
> >                 {
> >                         return val ? "true" : "false";
> >                 }
> >
> >                 public bool foo ()
> > 		{
> > 			if (bar (5) > 10) {
> > 				val = false;
> > 				return false;
> > 			} else {
> > 				val = true;
> > 				return true;
> > 			}
> > 		}
> >
> >                 public bool literal {
> >                         get {
> >                                 return val;
> >                         }
> >                         set {
> >                                 val = value;
> >                         }
> >         }
> > }
> >
> >
> > _______________________________________________
> > Mono-list maillist  -  Mono-list@ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-list
> >
>
>
> _______________________________________________
> Mono-list maillist  -  Mono-list@ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>