This Coding Standard requires certain practices for developing programs in the C# language. The objective of this coding standard is to have a positive effect on
This standard pertains to the use of the C# language. With few exceptions, it does not discuss the use of the .NET class libraries.
The standard is an extension to the Microsoft's Framework Design Guidelines ([Microsoft Framework]).
This standard does not include rules on naming conventions or how to layout code in general. It is recommended to adopt a separate style guide for this.
Reasons to have a coding standard and to comply with it are not given here, except the objectives listed in section 1.1. In this section the origins of the rules are given and some explanation why these were chosen.
Some general good practices, most of them concerning Object-Oriented programming, were copied from the Philips Healthcare C++ Coding Standard ([C++ Coding Standard]). Another source from which rules have been adopted is the Aviva C# coding guidelines ([Aviva]).
The numbering scheme and some of the structure have been copied from [C++ Coding Standard].
A considerable part of a coding standard for C or C++ could be condensed into a single rule, avoid undefined behavior, and maybe shun implementation defined behavior. Officially C# does not exhibit any of these, barring a few minor, well-defined exceptions. Most examples of undefined behavior in C++ will cause an exception to be thrown in C#. Although this is an improvement on the "anything might happen" of C++, it is highly undesirable for post-release software.
This coding standard applies to all C# code that is part of Philips Healthcare software products or directly supportive to these products. Third party software is constrained by this standard if this software is developed specifically for Philips Healthcare.
A rule should be broken only for compelling reasons where no reasonable alternative can be found. The author of the violating code shall consult with at least one knowledgeable colleague and a (senior) designer to review said necessity. A comment in the code explaining the reason for the violation is mandatory.
Rules in this coding standard are marked checkable if automatic verification of compliance is enforced by static analyzers.
Please note that the source code formatting in some examples has been chosen for compactness rather than for demonstrating good practice. The use of a certain compact style in some of the examples is considered suitable for tiny code fragments, but should not be emulated in 'real' code.