This repository was archived by the owner on Mar 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Style Guide
Mark Cafaro edited this page Apr 15, 2014
·
1 revision
This page covers the coding conventions used throughout the Symphony code base.
This list is not exhaustive. In general, follow the coding style of the file you are modifying.
This section covers all MATLAB code outside of the Core Stubs.
- Separate properties and events blocks with a single blank line
properties (Constant, Abstract)
identifier
version
end
properties
state
end
events
StateChanged
end
- Separate methods and function blocks with two blank lines (except for the first and last function in a methods block)
properties
identifier
end
methods
function setState(obj)
...
end
function requireDeviceNames(obj)
...
end
function prepareProtocol(obj)
...
end
end
- Function/method declaration: No space between variables and surrounding brackets/parentheses, a comma and one space between input and output variable names, no brackets unless required for multiple outputs, no space following function name
function myFunction()
function out = myFunction(obj, in)
function [out1, out2, out3] = myFunction(obj, in1, in2)
- Function/method calls should match the spacing format of function declarations
myFunction()
out = obj.myFunction(in)
[out1, out2, out3] = obj.myFunction(in1, in2)
- Anonymous functions: No space between input arguments, no space between parentheses and function body
@(in1,in2)in1 + in2;
- Attributes: One space between keywords and attribute specifications, one space between each attribute
properties (Constant, Abstract)
methods (SetAccess = protected, Abstract)
-
Use 4 spaces instead of tabs (the MATLAB editors default)
-
In general, add a space after a comma. Vector/cell indices and anonymous function inputs are possible exceptions.
- Class names are UpperCamelCase
classdef SymphonyProtocol
- Property names are lowerCamelCase
properties
rigPrepared
epoch
epochKeywords
end
- Function/method names are lowerCamelCase
function setState(obj)
- Event names are UpperCamelCase
events
FigureClosed
end
- Local variables are lowerCamelCase
function names = parameterNames(obj, includeConstants)
localVariable = includeConstants;
epoch
- Classes should follow this general order:
- Properties blocks
- Events blocks
- Public methods
- Private methods
- Private functions
- Order methods by tasks
- Split lines over 120 columns (set Right-hand text limit to 120 columns in MATLAB preferences)
- Check out The Elements of Matlab Style.
Follow the C# coding convention as closely as possible. This will make it easier to maintain the stubs in parallel with the core.
This section covers all C# code. In general we try to follow the Microsoft C# Coding Conventions. Deviations from these guidelines (if any) are listed below.