[mapguide-internals] RE: Coding Standards

Walt Welton-Lair walt.welton-lair at autodesk.com
Mon Jul 14 16:27:00 EDT 2008


"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.



Walt





-----Original Message-----
From: mapguide-internals-bounces at lists.osgeo.org [mailto:mapguide-internals-bounces at lists.osgeo.org] On Behalf Of Jason Birch
Sent: Monday, July 14, 2008 3:40 PM
To: MapGuide Internals Mail List
Subject: [mapguide-internals] Coding Standards



Hi all,



I've just finished converting a document Bruce provided which lays out

the standards to be used when working on MapGuide core code.



http://trac.osgeo.org/mapguide/wiki/MapGuideCodingStandards



Comments / corrections welcome.



Jason

_______________________________________________

mapguide-internals mailing list

mapguide-internals at lists.osgeo.org

http://lists.osgeo.org/mailman/listinfo/mapguide-internals


More information about the mapguide-internals mailing list