Skip to content

Naming Conventions

Leandro edited this page Mar 16, 2018 · 5 revisions

Naming Conventions

The RDMP aims to follow the Microsoft Design Guidelines for working with .Net

https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/

Summary

The Microsoft standard is basically (note: See RDMP Deviations below):

  • PascalCase for all public properties, class names, methods etc
  • cammelCase for all private properties and local variables within methods (and parameter names of methods)
  • Abbreviations should not be all caps
  • Underscores should be avoided entirely
  • Use Hungarian notation ONLY with form controls (btnSave, lblHeader, etc.)
public class MyClass
{
    //Public so Pascal case
    public int CurrentAge { get; set; }
    
    //Abbreviations of 3+ length should not be capitalised
    public object MyXmlValidator { get; set; }

    //Public so Pascal case but with cammel case parameter
    public void AddOne(string age)
    {
        //local variable so cammel case
        var agePlusOne = age + 1;
    }
}

RDMP Deviations

  • Private class variables are allowed to start with underscores e.g.
public class MyClass
{
    private readonly int _myMaxCounter;
}
  • Underscores are permitted in Tests
public class SetupDatasetTest
{
    [Test]
    public void EndToEnd_TestDatasetEnvironment()
    {
    }
}
  • Underscores are permitted in private UI methods/callbacks
public class MyUIClass : UserControl
{
    private OlvColumn olvDataType;
    private OlvColumn olvName;

    private object olvDataType_AspectGetter(object rowObject)
    {
        return rowObject.GetType();
    }

    private object olvName_AspectGetter(object rowObject)
    {
        var named = rowObject as INamed;
        return named != null ? named.Name: null;
    }
  • Nobody is perfect

Try to stick to these restrictions but don't correct existing code unless it's low impact fix (unlikely to affect plugin developers).

Visual Studio Projects / Solution Folders / Namespaces must exactly match physical disk

There is one solution file (.sln) which should reference all the projects (.csproj files). Each csproj file should be in a physical folder on disk which exactly matches the default namespace of the solution and there should be a corresponding Solution Folder declared in the .sln file.

So for example if you want a new area of functionality called AlienAbduction then you would first create a folder in the repository root called AlienAbduction then open the .sln file and create a 'New Solution Folder' AlienAbduction. Then add your new Project(s) with the Location being the AlienAbduction folder.

Once you have done this, run the integration test EvaluateNamespacesAndSolutionFoldersTests. It should tell you if you have done it right.