-
Notifications
You must be signed in to change notification settings - Fork 37
Coding standards
Committed code should adhere to the SOLID principles. GiveCRM uses Ninject to handle dependency injection, and has been configured to auto-wire concrete classes to interfaces using the convention IFoo
resolves to a class called Foo
.
Variables, methods, classes and all other identifiers should have meaningful and descriptive names.
All code introduced should be covered by unit tests at a minimum, with integration tests and acceptance tests where appropriate. Unit tests should be:
- Explicitly named
- Short (max. ~12 lines)
- Very fast to run (a few milliseconds per test method)
- Follow the Arrange-Act-Assert pattern
Technical debt should be paid down when it starts to hurt. Have you found a bit of the codebase that doesn't adhere to these rules? Tidy it up and submit a pull request!
To help code maintainability and readability StyleCop will be used to enforce a few rules. Currently all projects are using the one setting file found in the src directory. A ReSharper settings file provides development-time assistance in conforming to the GiveCRM coding standards.
Always include curly braces (this means you can't miss out curly braces on single line if blocks)
Unnecessary code must be removed.
- Access modifiers must be declared
- Fields must be private
- Code analysis suppression must have justification
-
Debug.Assert
s must provide a text message -
Debug.Fail
must provide a text message
- Interface names must begin with an I
- Const field names must begin with an upper case letter
- Field names must not use Hungarian notation
- Field names must begin with a lower case letter
- Variable names must not be prefixed (no putting _ or m_ infront of them)
- Field names must not begin with an underscore
const
s must appear before fields.
- Comments must contain text
- Don't use
region
s - Code must not contain empty statements
- Use
string.Empty
not""