[Mono-list] Style

Miguel de Icaza miguel@ximian.com
01 Mar 2002 04:15:47 -0500


Hello Jason!

> (I'm just guessing as to what you might want in these examples. Please
> correct me.)

Thanks for bringing this up, I have updated the document in the CVS:

> 
> // try/catch/finally
> // braces on the same line?
> try {
>     Foo ();
> } catch {Exception e) {
>     Bar ();
> }

Yes ;-)

> // switch
> // indent the cases?
> switch {
>     case 0:
>         Foo ();
>         break;
>     default:
>         Bar ();
>         break;
> }

This other way (which is the default for Emacs):

	switch (c) {
	case 'a':
		...
	case 'b':
		...
	}


> // indexer
> // space before the open bracket?
> string this [int i] {
>     get {
>         return foo;
>     }
> }

Yes, exactly.

> // what about invoking an indexer or array?
> // space before the open bracket?
> string foo = bar [1];

Exactly like that.

> // namespace
> // brace on the same line?
> namespace System {
> }

I do not particularly care about this one, I guess we need to see what
is most commonly used here, I think there is a large mix.

> // how do we indent long parameters?
> void Method (int this, string method, bool has, char way, float too,
>     double many, byte parameters)
> {
> }

I try to fit as many things as possible in 110 columns, but we should
probably standarize in 80 columns.  And the indentation follows the
first argument, like this:

	void Method (Type the_type, ParamemeterSomething la_la_la,
		     string first_string)

You will not see me complaining if you feel your code is more readable
 with the one-argument per-line structure, that seems fine as well. 

> What about naming guidelines? PascalCase, camelCase, _leading_underscores?

For any public methods, we follow the Microsoft guidelines (just to be
compatible).  

I personally have never liked the m_xxx or _xxx as a naming convention
for my instance variables, so I rather keep the instance variables with
lower case names, like this:

	string full_name;

> Should the example for "Missing implementation bits" throw
> NotImplementedException instead of a generic Exception?

Yes, you are absolutely right.

> I'm not trying to start any sort of debate. I just want to know what you
> want so that I can make sure to give it to you. :-)

I appreciate your comments a lot, there was a big void in the
guidelines, thanks for bringing this up ;-)

Miguel