[Mono-list] Class Library coding standards

Patrik Torstensson Patrik.Torstensson@framfablabs.com
Wed, 18 Jul 2001 21:58:41 +0200


Should we not keep the style simple meaning opening brace is always the
line under like:

		public void Touch(string strKey)
		{
			// Just touch the object
			Get(strKey);
		}

And not:

		public void Touch(string strKey) {
			// Just touch the object
			Get(strKey);
		}

And:
			if (bar (5) > 10) 
			{
				val = false;
			} else
			{
				val = true
			}

			return val;

I have used that syntax anyway because the editor keep correcting me..
;-)

And do "we" have a standard for naming conventions? I find it hard due
to the fact we are in a object/class world now and not the old C/C++ but
I tend to use the following syntax:

Parameters starting with a "_" is class members
Everything is camel syntax like objMyClassManager, strKey objValue etc.

I'm using the C# types as prefixs, give a clearer picture when reading
the code.

Comments?

Migaul, System.Web.Cache is now 50% finished but it has some nasty
dependencies towards System.Web.HttpRuntime but I will make it finish so
people can use it without the runtime also.

- Patrik

-----Original Message-----
From: Sean MacIsaac [mailto:macisaac@ximian.com] 
Sent: den 18 juli 2001 21:45
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