Changes between Version 7 and Version 8 of MapGuideCodingStandards


Ignore:
Timestamp:
07/14/08 11:09:35 (16 years ago)
Author:
jbirch
Comment:

Formatting

Legend:

Unmodified
Added
Removed
Modified
  • MapGuideCodingStandards

    v7 v8  
    9191== Threading Guidelines ==
    9292
    93 It’s important to follow strict threading rules when writing new code. Some of the MapGuide code will be used in a multithreaded deployment environment. Failing to follow multi-threading guidelines will be costly in the future. There are detailed guidelines provided by Microsoft's ''Design Guidelines for Class Library Developers'' ([ms-help://MS.VSCC/MS.MSDNVS/cpgenref/html/cpconnetframeworkdesignguidelines.htm local VS link]) that should be reviewed.
     93It’s important to follow strict threading rules when writing new code. Some of the !MapGuide code will be used in a multithreaded deployment environment. Failing to follow multi-threading guidelines will be costly in the future. There are detailed guidelines provided by Microsoft's ''Design Guidelines for Class Library Developers'' ([ms-help://MS.VSCC/MS.MSDNVS/cpgenref/html/cpconnetframeworkdesignguidelines.htm local VS link]) that should be reviewed.
    9494
    9595Here are some points from those guidelines:
     
    102102== Source File Naming ==
    103103
    104 The naming of source code files will match the class names except that the “Mg” prefix will be dropped.  For example, if I have a class called !MgClassA then all source files for that class will have the name !ClassA.  If this class is defined in C#, then there is only one source file with the .cs extension.  If this class is defined in C++, then there are two files: the source file with extension .cpp and the header file with extension .h.  No mismatches between class names and file names are allowed!
     104The naming of source code files will match the class names except that the “Mg” prefix will be dropped.  For example, if I have a class called MgClassA then all source files for that class will have the name ClassA.  If this class is defined in C#, then there is only one source file with the .cs extension.  If this class is defined in C++, then there are two files: the source file with extension .cpp and the header file with extension .h.  No mismatches between class names and file names are allowed!
    105105
    106106One consequence of this rule is that you can only define one class/enumeration/struct/interface per file.
    107107
     108== Folder Hierarchy ==
     109
     110Just as the file name reflects the class name, the folder hierarchy will reflect the namespace or module hierarchy.  If MgClassA is defined in the namespace OSGeo.!MapGuide.!DataAccess, then relative to the project root all source files for MgClassA will reside in the OSGeo\!MapGuide\!DataAccess folder.  You will see this hierarchy reflected in the source control application.  Again, having the hierarchies match up makes it very easy to navigate to where you want to go.
     111
     112A consequence of this rule is that if you change a namespace or module then you will also have to rename or restructure the file hierarchy.
     113
     114== Deleting Files and Projects ==
     115
     116Eventually everyone needs to remove files and/or projects from the main source.  If you’re removing files, you update the Visual Studio solution file and if applicable the Linux build script.  Having done this, you still need to remove the file / project from the source control application.
     117
     118== General Structure of !MapGuide Files
     119
     120We would like all !MapGuide files to have a similar structure:
     121
     122 1. Copyright info
     123   * every source file must have this at the top
     124   * the actual text in the copyright is subject to change, but that doesn’t mean we shouldn’t add it
     125   * whenever you create a new file, find another file with the copyright and paste that into your new file
     126 1. Import of .NET namespaces (If applicable)
     127   * ideally sorted alphabetically
     128 1. Import of local namespaces (If applicable)
     129   * ideally sorted alphabetically
     130 1. Namespace info (If applicable)
     131   * as mentioned above, the namespace matches the folder path of the source file(s)
     132 1. Class declaration
     133   * includes seed documentation
     134 1. Constant declarations
     135 1. Local variable declarations
     136 1. Inner classes separated by section comments (If applicable)
     137 1. Constructors
     138 1. Properties/methods
     139
     140 
     141For example:
     142{{{
     143#!cpp
     144//
     145//  Copyright (C) 2004-2008 by Autodesk, Inc.
     146//
     147//  This library is free software; you can redistribute it and/or
     148//  modify it under the terms of version 2.1 of the GNU Lesser
     149//  General Public License as published by the Free Software Foundation.
     150//
     151//  This library is distributed in the hope that it will be useful,
     152//  but WITHOUT ANY WARRANTY; without even the implied warranty of
     153//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     154//  Lesser General Public License for more details.
     155//
     156//  You should have received a copy of the GNU Lesser General Public
     157//  License along with this library; if not, write to the Free Software
     158//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     159//
     160
     161using System;
     162using System.Runtime.Serialization;
     163
     164namespace OSGeo.MapGuide.DataAccess.Tools
     165{
     166    /// <summary>
     167    /// Provides the base functionality for ...
     168    /// </summary>
     169    [Serializable]
     170    public class MyClass : ISerializable
     171    {
     172        //-------------------------------------------------------
     173        // Constants
     174        //-------------------------------------------------------
     175        Constants
     176
     177        //-------------------------------------------------------
     178        // Variables
     179        //-------------------------------------------------------
     180        Variables
     181
     182        //-------------------------------------------------------
     183        // Inner classes
     184        //-------------------------------------------------------
     185        Inner classes
     186
     187        //-------------------------------------------------------
     188        // Constructors
     189        //-------------------------------------------------------
     190        Constructors
     191
     192        //-------------------------------------------------------
     193        // Properties / Methods
     194        //-------------------------------------------------------
     195        Properties / Methods
     196    }
     197}
     198}}}
     199
     200