Coding Standards

View: New views
19 Messages — Rating Filter:   Alert me  

Coding Standards

by JasonBirch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals

RE: Coding Standards

by haris kurtagic :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jason,
I read this line " Parts of MapGuide will be based on Microsoft's .NET
framework' ".
I know Maestro is .NET. Are there any parts/plans ?
First look of document gives impression to me that it is lot of.NET in
MG.

Haris

-----Original Message-----
From: mapguide-internals-bounces@...
[mailto:mapguide-internals-bounces@...] On Behalf Of Jason
Birch
Sent: Monday, July 14, 2008 9: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@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals
_______________________________________________
mapguide-internals mailing list
mapguide-internals@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals

Re: Coding Standards

by Kenneth Skovhede, GEOGRAF A/S :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

What are the motivations for avoiding variable declaration inside the
for loop construction?
I personally find it much cleaner to put it in there, because the
variable is not accesible outside
the loop scope, which is usually not desireable.

The "i" variable is usually very local, and it makes sense to re-declare
it for a loop following
another loop, rather than re-use it for another purpose.

(Hoping not to start a holy war on coding standards :)

The "finally" is actually not "always" executed, if there is an
exception thrown in the exception handler.
(Its not a "how-to-program" guide, so that may not matter.)

Other than that, it looks good to me.

Regards, Kenneth Skovhede, GEOGRAF A/S



Jason Birch skrev:

> 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@...
> http://lists.osgeo.org/mailman/listinfo/mapguide-internals
>  
_______________________________________________
mapguide-internals mailing list
mapguide-internals@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals

RE: Coding Standards

by Walt Welton-Lair :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Much of this document was written back when MapGuide 1.0 was in development.  The sentence you referenced should now read "Parts of MapGuide are based on Microsoft's .NET framework."

Walt

-----Original Message-----
From: mapguide-internals-bounces@... [mailto:mapguide-internals-bounces@...] On Behalf Of Haris Kurtagic
Sent: Monday, July 14, 2008 4:02 PM
To: MapGuide Internals Mail List
Subject: RE: [mapguide-internals] Coding Standards

Hi Jason,
I read this line " Parts of MapGuide will be based on Microsoft's .NET
framework' ".
I know Maestro is .NET. Are there any parts/plans ?
First look of document gives impression to me that it is lot of.NET in
MG.

Haris

-----Original Message-----
From: mapguide-internals-bounces@...
[mailto:mapguide-internals-bounces@...] On Behalf Of Jason
Birch
Sent: Monday, July 14, 2008 9: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@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals
_______________________________________________
mapguide-internals mailing list
mapguide-internals@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals
_______________________________________________
mapguide-internals mailing list
mapguide-internals@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals

RE: Coding Standards

by Walt Welton-Lair :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

"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@... [mailto:mapguide-internals-bounces@...] 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@...

http://lists.osgeo.org/mailman/listinfo/mapguide-internals
_______________________________________________
mapguide-internals mailing list
mapguide-internals@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals

RE: Coding Standards

by JasonBirch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I've changed this.

Haris, I wikified the document, but can't comment on the specifics
because I'm generally clueless ;)

Jason

-----Original Message-----
From: Walt Welton-Lair
Subject: RE: [mapguide-internals] Coding Standards

Much of this document was written back when MapGuide 1.0 was in
development.  The sentence you referenced should now read "Parts of
MapGuide are based on Microsoft's .NET framework."
_______________________________________________
mapguide-internals mailing list
mapguide-internals@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals

RE: RE: Coding Standards

by JasonBirch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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.
_______________________________________________
mapguide-internals mailing list
mapguide-internals@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals

RE: Coding Standards

by JasonBirch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm not sure either, other than the SWIG-generated wrapper for the web
tier.

OTOH, I don't think that we need to worry about that too much.
Hopefully developers won't be reading this without having looked at the
code a few times first... :)

Jason

-----Original Message-----
From: Haris Kurtagic
Subject: RE: [mapguide-internals] Coding Standards

Thanks Walt, Jason.

I see you changed to "Parts are" but still , I don't know which parts
are .NET :)

What I would like to point out is that I think by reading this someone
would get feeling that main/large part of MapGuide is in .NET.

Haris
_______________________________________________
mapguide-internals mailing list
mapguide-internals@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals

RE: Coding Standards

by haris kurtagic :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Walt, Jason.

I see you changed to "Parts are" but still , I don't know which parts
are .NET :)

What I would like to point out is that I think by reading this someone
would get feeling that main/large part of MapGuide is in .NET.

Haris


-----Original Message-----
From: mapguide-internals-bounces@...
[mailto:mapguide-internals-bounces@...] On Behalf Of Jason
Birch
Sent: Monday, July 14, 2008 10:27 PM
To: MapGuide Internals Mail List
Subject: RE: [mapguide-internals] Coding Standards

I've changed this.

Haris, I wikified the document, but can't comment on the specifics
because I'm generally clueless ;)

Jason

-----Original Message-----
From: Walt Welton-Lair
Subject: RE: [mapguide-internals] Coding Standards

Much of this document was written back when MapGuide 1.0 was in
development.  The sentence you referenced should now read "Parts of
MapGuide are based on Microsoft's .NET framework."
_______________________________________________
mapguide-internals mailing list
mapguide-internals@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals
_______________________________________________
mapguide-internals mailing list
mapguide-internals@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals

RE: Coding Standards

by Tom Fukushima :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This looks like http://mapguide.osgeo.org/generalcodingguidelines.html which is pointed to from http://mapguide.osgeo.org/developer.html.  Are they the same?

Another document there http://mapguide.osgeo.org/apicodingguidelines.html also has some guidelines.

I suspect we will replace the first link above with our new version.  Jason, could you do the same with our "apicodingguidelines" doc?

I have some changes from about a year ago that need to go into the general guidelines from Steve; looks like I'll have to get off my butt, dig them up and get them into the wiki version.



-----Original Message-----
From: mapguide-internals-bounces@... [mailto:mapguide-internals-bounces@...] On Behalf Of Jason Birch
Sent: Monday, July 14, 2008 1: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@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals
_______________________________________________
mapguide-internals mailing list
mapguide-internals@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals

RE: RE: Coding Standards

by JasonBirch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Well darn... time to just retire the www site :)  I have no idea if they
are the same.  Bruce?

Yes, when I can find some time (I've got something to do for Haris
first) I'll try to convert the API standards doc as well.  Is there a
newer internal version I should be working from?

Jason

-----Original Message-----
From: Tom Fukushima
Subject: [mapguide-internals] RE: Coding Standards

This looks like http://mapguide.osgeo.org/generalcodingguidelines.html
which is pointed to from http://mapguide.osgeo.org/developer.html.  Are
they the same?

Another document there
http://mapguide.osgeo.org/apicodingguidelines.html also has some
guidelines.

I suspect we will replace the first link above with our new version.
Jason, could you do the same with our "apicodingguidelines" doc?

I have some changes from about a year ago that need to go into the
general guidelines from Steve; looks like I'll have to get off my butt,
dig them up and get them into the wiki version.


_______________________________________________
mapguide-internals mailing list
mapguide-internals@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals

RE: RE: Coding Standards

by Bruce Dechant :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

They are the same. :)

I didn't even know the other location existed, but it was taken from the same source document.

Bruce

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

Well darn... time to just retire the www site :)  I have no idea if they
are the same.  Bruce?

Yes, when I can find some time (I've got something to do for Haris
first) I'll try to convert the API standards doc as well.  Is there a
newer internal version I should be working from?

Jason

-----Original Message-----
From: Tom Fukushima
Subject: [mapguide-internals] RE: Coding Standards

This looks like http://mapguide.osgeo.org/generalcodingguidelines.html
which is pointed to from http://mapguide.osgeo.org/developer.html.  Are
they the same?

Another document there
http://mapguide.osgeo.org/apicodingguidelines.html also has some
guidelines.

I suspect we will replace the first link above with our new version.
Jason, could you do the same with our "apicodingguidelines" doc?

I have some changes from about a year ago that need to go into the
general guidelines from Steve; looks like I'll have to get off my butt,
dig them up and get them into the wiki version.


_______________________________________________
mapguide-internals mailing list
mapguide-internals@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals
_______________________________________________
mapguide-internals mailing list
mapguide-internals@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals

RE: RE: Coding Standards

by Bruce Dechant :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

One other thing - great feedback everyone!

Bruce

-----Original Message-----
From: mapguide-internals-bounces@... [mailto:mapguide-internals-bounces@...] On Behalf Of Bruce Dechant
Sent: Monday, July 14, 2008 3:25 PM
To: MapGuide Internals Mail List
Subject: RE: [mapguide-internals] RE: Coding Standards

They are the same. :)

I didn't even know the other location existed, but it was taken from the same source document.

Bruce

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

Well darn... time to just retire the www site :)  I have no idea if they
are the same.  Bruce?

Yes, when I can find some time (I've got something to do for Haris
first) I'll try to convert the API standards doc as well.  Is there a
newer internal version I should be working from?

Jason

-----Original Message-----
From: Tom Fukushima
Subject: [mapguide-internals] RE: Coding Standards

This looks like http://mapguide.osgeo.org/generalcodingguidelines.html
which is pointed to from http://mapguide.osgeo.org/developer.html.  Are
they the same?

Another document there
http://mapguide.osgeo.org/apicodingguidelines.html also has some
guidelines.

I suspect we will replace the first link above with our new version.
Jason, could you do the same with our "apicodingguidelines" doc?

I have some changes from about a year ago that need to go into the
general guidelines from Steve; looks like I'll have to get off my butt,
dig them up and get them into the wiki version.


_______________________________________________
mapguide-internals mailing list
mapguide-internals@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals
_______________________________________________
mapguide-internals mailing list
mapguide-internals@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals
_______________________________________________
mapguide-internals mailing list
mapguide-internals@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals

RE: RE: Coding Standards

by JasonBirch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Looked at them a bit.  They are similar but not the same.  Structured
differently, with .Net/C++ specific stuff at the bottom on the web site.
Also, document structure guidelines seems to be duplicated?

Jason

-----Original Message-----
From: Bruce Dechant
Subject: RE: [mapguide-internals] RE: Coding Standards

They are the same. :)

I didn't even know the other location existed, but it was taken from the
same source document.

Bruce
_______________________________________________
mapguide-internals mailing list
mapguide-internals@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals

RE: Coding Standards

by Steve Dang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The sentence under the "Strings : Across Wire" section:

"The UTF-8 standard will be used for transmitting strings across the wire between any of the MapGuide products (client, web tier, and server)."

should be read as:

"The UTF-16 standard will be used for transmitting strings across the wire between any of the MapGuide products (client, web tier, and server)."

Thanks,
Steve.

-----Original Message-----
From: mapguide-internals-bounces@... [mailto:mapguide-internals-bounces@...] On Behalf Of Jason Birch
Sent: Monday, July 14, 2008 1: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@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals
_______________________________________________
mapguide-internals mailing list
mapguide-internals@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals

RE: RE: Coding Standards

by JasonBirch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

But not the resource repository?

-----Original Message-----
From: Steve Dang
Subject: [mapguide-internals] RE: Coding Standards

The sentence under the "Strings : Across Wire" section:

"The UTF-8 standard will be used for transmitting strings across the
wire between any of the MapGuide products (client, web tier, and
server)."

should be read as:

"The UTF-16 standard will be used for transmitting strings across the
wire between any of the MapGuide products (client, web tier, and
server)."

Thanks,
Steve.
_______________________________________________
mapguide-internals mailing list
mapguide-internals@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals

RE: RE: Coding Standards

by Steve Dang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Correct!

-----Original Message-----
From: mapguide-internals-bounces@... [mailto:mapguide-internals-bounces@...] On Behalf Of Jason Birch
Sent: Tuesday, July 15, 2008 9:50 AM
To: MapGuide Internals Mail List
Subject: RE: [mapguide-internals] RE: Coding Standards

But not the resource repository?

-----Original Message-----
From: Steve Dang
Subject: [mapguide-internals] RE: Coding Standards

The sentence under the "Strings : Across Wire" section:

"The UTF-8 standard will be used for transmitting strings across the
wire between any of the MapGuide products (client, web tier, and
server)."

should be read as:

"The UTF-16 standard will be used for transmitting strings across the
wire between any of the MapGuide products (client, web tier, and
server)."

Thanks,
Steve.
_______________________________________________
mapguide-internals mailing list
mapguide-internals@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals
_______________________________________________
mapguide-internals mailing list
mapguide-internals@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals

RE: RE: Coding Standards

by JasonBirch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

OK fixed :)

-----Original Message-----
From: Steve Dang
Subject: RE: [mapguide-internals] RE: Coding Standards

Correct!

-----Original Message-----
From: Jason Birch
Subject: RE: [mapguide-internals] RE: Coding Standards

But not the resource repository?

-----Original Message-----
From: Steve Dang
Subject: [mapguide-internals] RE: Coding Standards

The sentence under the "Strings : Across Wire" section:

should be read as:

"The UTF-16 standard will be used for transmitting strings across the
wire between any of the MapGuide products (client, web tier, and
server)."
_______________________________________________
mapguide-internals mailing list
mapguide-internals@...
http://lists.osgeo.org/mailman/listinfo/mapguide-internals