[Mono-list] Style

Dwivedi , Ajay Kumar AjayKumar.Dwivedi@dresdner-bank.com
Sat, 2 Mar 2002 11:34:06 -0000


> As Linus writes, in the kernel's CodingStyle:
<snip>
>   In short, 8-char indents make things easier to read, and have the
>   added benefit of warning you when you're nesting your functions too
>   deep.  Heed that warning. 
> 
> This is a very good argument for using 8-space identation.

	Not exactly. Those arguments work for C/C++, not in C#.
Three levels of indentation is *minimum* in C# (or java for that matter).
namespace starts on column 1
class declaration at first level
method at second level, 
accessor methods for a property at third level. 
If you have a if condition in the code inside the if condition is at 5
levels of indentation. 
With a 8 spaces per indentation, its 40 charcter indentation (1/2 of the
screen).

	IMO TAB based indentation is the best, atleast people have the
choice of setting the tabsize.
	
Check this out on a 80 char display:

namespace System
{
        public class Test
        {
                private bool isTrue;

                public int SomeProperty
                {
                        get
                        {
                                if(isTrue)
                                {
                                        return 1;
                                }
                                else
                                {
                                        return 0;
                                }
                        }
                }
        }
}

Happy Hacking,
Ajay