This page applies to source code files developed in C# for IFS Enterprise Explorer.
Source files should be kept as short as possible. Put every class in a separate file, and name that file like the class followed by the .cs extension.
Note: The file name should describe the class not the position in the class hierarchy.
Organize the material in each source file as follows:
using System; using System.Drawing; namespace Ifs.Fnd.Core { public class FndSample { public event EventHandler SampleEvent; private int myInt; public FndSample(int myInt) { this.myInt = myInt ; } private void Inc() { ++myInt; } } }
Example 1: Correct order of declarations
Within the class when declaring instance variables and
events (SampleEvent & myInt above), declare and group public
variables first,
then protected
, then internal
and then private
.
Don’t mix these like this:
private int myString; public event EventHandler SampleEvent; private int myInt; public event EventHandler SampleEvent2;
Source code file headers should use the default header from the template when they are created. When making a significant change to a source file, you can add a comment in the header with a short description of your work. The latest change shall be at the top of the history.
#region Copyright (c) IFS Research & Development // // IFS Research & Development // // This program is protected by copyright law and by international // conventions. All licensing, renting, lending or copying (including // for private use), and all other use of the program, which is not // explicitly permitted by IFS, is a violation of the rights // of IFS. Such violations will be reported to the // appropriate authorities. // // VIOLATIONS OF ANY COPYRIGHT IS PUNISHABLE BY LAW AND CAN LEAD // TO UP TO TWO YEARS OF IMPRISONMENT AND LIABILITY TO PAY DAMAGES. #endregion #region History #endregion
Example 2: Source File Header with mock-up history
Note: The file header template may change over time, so any given file might have a different header. All source file headers must have a header, though.