[mapguide-internals] RE: Coding Standards
Jason Birch
Jason.Birch at nanaimo.ca
Mon Jul 14 16:37:11 EDT 2008
I've changed it to read:
"The guideline is to avoid using break statements inside loops and to
use goto sparingly (if at all)."
And added the section on object creation.
Jason
-----Original Message-----
From: Walt Welton-Lair
Subject: [mapguide-internals] RE: Coding Standards
"The guideline is to avoid using break statements inside loops and to
forbid the use of goto."
forbidding goto is silly - it should simply be used sparingly
Let's also add this blurb under "Object Creation and Runtime Speed".
It's a thing I see fairly frequently.
When you do need to create objects, check if it's possible to create
them on the stack rather than on the heap. Consider the following
example:
Ptr<MgFoo> spFoo = new MgFoo(arg);
Bar(spFoo);
In this case MgFoo is a ref-counted object, and because of this you
might think your only choice is call to new and assign the result to a
smart pointer. In fact, if the call to Bar does not add any references
to the object then the following code which doesn't call new also works:
MgFoo foo(arg);
Bar(&foo);
Of course the same stack vs. heap thinking applies to non-ref-counted
objects.
More information about the mapguide-internals
mailing list