This project is read-only.

Coding Conventions and Guidelines

1. Avoid having lines more than 100 symbols.

2. Prefix class fields with "m", static members with "g" and constants with all capital letters:
  public class TimelineBuilder
        private const double                            TOP_MARGIN = 5;
        private double                                  m_pixelWidth;
        private double                                  m_pixelHeight;

3. Align variables, parameters and fields at position 57.
   public object CreateColumn(
       double                                      left, 
       double                                      top, 
       double                                      width, 
       double                                      height, 
       string                                      content
        FrameworkElement                           el;

4. Avoid initialization of local variables at the time of declaration with value which does not make sense. Consider the following example where return value may be left with invalid value:
   public decimal GetBalance(
       AccType                                           at
          decimal                                         ret = 0;

          if (at == AccType.SavingAccount)
                ret = GetSavings();
          else if (at == AccType.CheckingAccount)
                ret = GetChecking();

          return ret; 

5. Make member functions and properties work in transactional way, i.e. if member function fails object state is not altered.

6. Use Debug.Assert to validate assumptions about function parameters, or throw exception for public methods and properties.

7. Avoid having more then one try/catch/finally block inside a function.

8. Prefer single return from a function.

Z. For the rest follow .Net Framework Design Guidelines for Class Library Developers located here:

Last edited Oct 18, 2009 at 3:19 AM by andrewsyrov, version 20


No comments yet.