TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
C# Coding Standard

Philips Healthcare - C# Coding Standard

Version head

issued by the CCB Coding Standards Philips Healthcare


1.1. Objective

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

1.2. Scope

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.

1.3. Rationale

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.

1.3.1. Sources of inspiration

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].

1.3.2. Contrast with C++

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.

1.4. Applicability

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.

1.5. Notational conventions

1.5.1. Rule

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.

1.5.2. Checkable

Rules in this coding standard are marked checkable if automatic verification of compliance is enforced by static analyzers.

1.5.3. Examples

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.