[Mono-devel-list] REPOST: Mono class layout

Hayes, Dennis Dennis.Hayes at raytek.com
Tue Nov 11 15:31:44 EST 2003


/Rant on
Does anyone have so much spare time that they would like to explain why
sometimes the bracket goes on the same line and other times it goes on the
next line.
I know this comes from another "standard" (Java?).
Do people have this memorized? Do they look it up every time they use a
brace? Does Monostyle correct this? Do people just put all their braces one
way or the other and ignore this (like me - my bad)? 
/Rant off
Thanks,
Dennis

-----Original Message-----
From: Miguel de Icaza [mailto:miguel at ximian.com] 
Sent: Tuesday, November 11, 2003 1:03 PM
To: mono-devel-list at ximian.com

		* Inside a code block, put the opening brace on the same
line
	  	  as the statement:

			good:
				if (a) {
					code ();
					code ();
				}

			bad:
				if (a) 
				{
					code ();
					code ();
				}

		* When defining a method, use the C style for brace
placement, 
		  that means, use a new line for the brace, like this:

			good:
				void Method ()
				{
				}

			bad:
				void Method () {
				}

		* Properties and indexers are an exception, keep the
		  brace on the same line as the property declaration.
		  Rationale: this makes it visually
		  simple to distinguish them.

			good:
				int Property {
					get {
						return value;
					}
				}

			bad:
				int Property 
				{
					get {
						return value;
					}
				}

		  Notice how the accessor "get" also keeps its brace on the
same
		  line.

		  For very small properties, you can compress things:

			ok:
				int Property {
					get { return value; }
					set { x = value; }
				}

		* Use white space in expressions liberally, except in the
presence
		  of parenthesis:

			good:

				if (a + 5 > method (blah () + 4))

			bad:
				if (a+5>method(blah()+4))




More information about the Mono-devel-list mailing list