-
Notifications
You must be signed in to change notification settings - Fork 0
Coding Practices
Root Order
- x:Name, x:Class
- All references, maximum 2 per line
- Design properties (Ex. mc:Ignorable="d" d:DesignWidth="230" Foreground="Blue")
- ViewModelLocator?
- Bindings
Rules:
-Wrap lines when they pass more the longest reference line
Controls Properties Order
- x:Name
- Design properties
- Bindings
Example:
<Rectangle x:Name="rectangle1" Height="1" Width="200" Fill="{Binding FillColor}" />The FoundOps code structure is broken into these sections
Code Structure
1-2 of something(like properties or methods): use //
3 or more: enclose in #region/#endregion
All comments should start capitalized and use proper punctuation.
Class Structure:
//Summary
Properties & Variables
-Public
-Protected
-Locals
Constructors (least parameters => most parameters)
Logic(Always in a region)
Example property:
//Summary
private int _num
public int Num
{
get{...}
set{...}
}Logic Code Organization
Organize by:
- Code Execution
- Alphabetically
Example code execution section:
//Section explanation
//1st method called
//2nd method called
{
//inner method A
//inner method B
}Using Statements
Try to keep in order of shortest to longest
When you don't need to use the variable, you can use _ => for one variable or (_,__) for multiple variables.
Example:
AddCommand.Subscribe(_ => UpdateFilter());Separate the code like this:
// Update Filter whenever: a) routes are changed or is set, b) the SelectedRouteTypes changes,
// c) the SelectedRegions changes
var loadedRoutes = DataManager.GetEntityListObservable<Route>(Query.RoutesForServiceProviderOnDay);
//a) routes are changed or is set
loadedRoutes.FromCollectionChangedOrSetGeneric()
//b) the SelectedRouteType changes
.Merge(SelectedRouteTypes.FromCollectionChangedEventGeneric())
//c) the SelectedRegions changes
.Merge(SelectedRegions.FromCollectionChangedEventGeneric())Confusing seconds and milliseconds when using RX TimeSpan.
new TimeSpan(0,0,2) //2 seconds
new TimeSpan(0, 0, 0, 0, 300) //300 milliseconds See [http://msdn.microsoft.com/en-us/library/system.timespan.aspx](this link) for more information.