Sunday, 26 October 2008

Principles of C# Composition

#region William Strunk Jr, Principles of Composition (applies to programming as to prose)
"Make the paragraph the unit of composition: one paragraph to each topic".

#endregion

#region Windows Joe, Principles of C# Composition

  1. When storing dates in data structures use DateTimes rather than one of multiple string formats. There are special situations when it is preferable to use strings e.g. when all the strings in the application are guaranteed to be in the same format.
  2. Don't make assumptions about objects being reference or value types. Apart from user-defined classes and obvious things like ints, many objects in the .NET framework are inconsistently implemented - they may be values or references. ADO.NET in .Net 1.1 is an example. Use properties to get and set these variables explicitly rather than rely on reference-value semantics.
  3. Use object adapters. Avoid class adapters.
#endregion

No comments: