[Mono-list] Style
Christian Meyer
chrisime@uni.de
02 Mar 2002 17:28:32 +0100
Am Sam, 2002-03-02 um 16.16 schrieb Gaurav Vaish:
> : Well, you don't need to indent namespace and class declarations.
>
> The whole purpose of indentation will be lost! It not only beautifies the
> code but almost helps one to detect any errors in braces-matching, and unless
> you have intelligent SharpDevelop, emacs etc, you will be lost.
I agree. Currently I'm using the following indentation:
namespace mono.blabla
{
class public MyClass : MonoClass {
public string gimmeString() {
return "MONO";
}
}
}
As you can see, this looks rather ugly. I vote for indentation of class
declerations.
> Though the choice may be personal, I prefer the following:
> * Tab instead of a whitespace. If I am forced to use whitespace -- it will
> be width 4.
Personally, I hate tabs. They are looking quite ugly in vi(m). I don't
want to switch to emacs, because I think it sucks *flamewar* ;)
I'm currently using whitespaces with width=4.
> * Indentation with opening braces on a new line, like the one given towards
> the end.
> * So, where there are any '{' / '}' brace in a line, there are only braces.
I hope I did understand correctly:
class Test
{
blabla...
}
I don't like that. Before I went to university I thought this would be
the ultimate coding style. When I learned JAVA, I immediately switched
to:
class Test {
blabla...
}
It somehow looks better. AFAIK, the first style is used for C/C++ code
(I never saw different C/C++ style).
> * Even if there is only one statement to be executed in if-else, put them in
> braces, like one shown below.
> -> This gives liquidity for later use, where you may like to put some
> stuff. Everytime, you do, you will not have to bother about adding / deleting
> those braces.
I fully agree!
> [ Thank God, one-line methods have to be written within braces, or else think
> about the situation it would have been otherwise And the same thing with get /
> set ].
>
> namespace Vaish.Gaurav.Namespace
> {
> public class GauravVaish
> {
> public int Property1
> {
> get
> {
> if(someCheck())
> {
> return 0;
> } else
> {
> return 1;
> }
> }
> }
> }
> }
>:)
My version:
namespace mono.test
{
public class Test {
public void doNothing() {
return;
}
public int InstStuff {
get {
if (somethingRocks()) {
return 1;
}
else {
return 0;
}
}
set {
....
}
}
}
}
I'm always adding a blank line between the class definition and the
method defition.
I would agree about:
get
{
blabla
}
In your case the 'else case' style isn't very good IMO.
Any suggestions, ideas?!
Greetings
Christian