background preloader

Guidelines

Facebook Twitter

Standards

LINQ. What I look for in a Code Review. I recently put this bullet point list together for the team I’m currently working with.

What I look for in a Code Review

Naming Conventions Naming conventions. We will follow Microsoft’s standard C# naming conventions. Ignore the bit about putting using statements inside the namespace declaration. General Principles The core imperative is to organise complexity. Keep the source clean Always delete unused code. Naming things The name should accurately describe what the thing does. Namespaces Namespaces should match the project name + path inside the project. Variables Use constants where possible. Methods The name should accurately describe what the method does. Classes The name should accurately describe what the class does. Interfaces Rely on interfaces rather than concrete classes wherever possible.

Tests All code should have unit tests if possible. Error Handling Only wrap code with a try..catch statement if you are expecting it to throw a specific exception. Coding Guidelines. This document contains the coding guidelines for the Mono Project.

Coding Guidelines

It contains four major sections: Style Guidelines, on how to organize your source code. Git Workflow Changes discusses how our workflow has changed now that Mono is hosted on GitHub. Source Code Control details our source code control use. Best Practices, used in the project. In order to keep the code consistent, please use the following conventions. You may also wish to read the .Net Framework Design Guidelines as well, however the Mono guidelines below take precedent for Mono code if there is a conflict.

Indentation Use 8 space tabs for writing your code (hopefully we can keep this consistent). Since we are using 8-space tabs, you might want to consider the Linus Torvalds trick to reduce code nesting. For (i = 0; i < 10; i++) { if (something (i)) { do_more (); }} This takes precious space, instead write it like this: for (i = 0; i < 10; i++) { if (! Switch statements have the case at the same indentation as the switch: ok: Brad Abrams : Internal Coding Guidelines. 1. Introduction.......................................................................................................................................... 1 2. Style Guidelines.................................................................................................................................... 2 2.1 Tabs & Indenting................................................................................................................................ 2 2.2 Bracing............................................................................................................................................... 2 2.3 Commenting........................................................................................................................................ 2 2.3.1 Documentation Comments............................................................................................................. 2.

Design Guidelines for Developing Class Libraries. This section provides guidelines for designing libraries that extend and interact with the .NET Framework.

Design Guidelines for Developing Class Libraries

The goal is to help library designers ensure API consistency and ease of use by providing a unified programming model that is independent of the programming language used for development. We recommend that you follow these design guidelines when developing classes and components that extend the .NET Framework. Inconsistent library design adversely affects developer productivity and discourages adoption. The guidelines are organized as simple recommendations prefixed with the terms Do, Consider, Avoid, and Do not. These guidelines are intended to help class library designers understand the trade-offs between different solutions. These guidelines are excerpted from the book Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries, 2nd Edition, by Krzysztof Cwalina and Brad Abrams.