Changes between Version 14 and Version 15 of Development/CodeConventions
- Timestamp:
- 03/16/10 06:44:37 (3 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Development/CodeConventions
v14 v15 8 8 9 9 [[br]] 10 == General Rules ==10 == General Rules for all Languages == 11 11 12 * Tabs are 8 spaces. No discussion will be entered into on this point. 12 * Tabs are 8 spaces. The reason being that when you `cat` a text file to a unix console they come out as 8 spaces. No further discussion will be entered into on this point. 13 13 14 * We prefer literal tabs at the start of lines instead of hard spaces. 15 14 16 * Each top-level definition should have a comment explaining what it is for. One liners are fine. 17 15 18 * Running comments in the bodies of functions are encouraged. Write down what you were expecting the code to do when you wrote it, so it reads like a story. Aim for 1 comment line every 5-10 code lines, depending on how complex the code is. 16 19 … … 31 34 * All top-level bindings should have a type signature. Exceptions can be made for functions that are continuations of others, as they will never need to be called from outside the module they are defined in. 32 35 36 * Name conversion functions like ` globOfTops :: [Top] -> Glob ` instead of ` topsToGlob :: [Top] -> Glob`. The type may be the opposite way around compared to the name, but it makes the source code easier to read. Consider ` (globOfTops someTops) ` vs ` (topsToGlob someTops)`. 37 38 * If part of a variable name reflects its type, then put that part out the front. For example, source code variables of type `Shared.Var` should be named something like `vThing`, with a `v` out the front. Sets or lists of variables should be named `vsThing` with `vs` out the front. Avoid using names like `thingVar` and `thingVars`. 39 33 40 [[br]] 34 41 == Haskell / Disciple Specifics == 42 43 === Module signatures === 44 Like the this, with the commas on the left: 45 46 {{{ 47 module Thing 48 ( someFunction 49 , someOtherFunction 50 , moreStuff ) 51 where 52 ... 53 }}} 54 [[br]] 35 55 36 56 === Try to put the {{{do}}} on the same line as the {{{=}}} ===
