Browse Source

Coding standards update.

cl-refactor
Gav Wood 10 years ago
parent
commit
d119c6c188
  1. 20
      CodingStandards.txt
  2. 3
      alethzero/MainWin.h

20
CodingStandards.txt

@ -1,8 +1,11 @@
0. Formatting 0. Formatting
GOLDEN RULE: Never *ever* use spaces for formatting.
a. Use tabs for indentation! a. Use tabs for indentation!
- tab stops are every 4 characters. - tab stops are every 4 characters.
- One indentation level -> exactly one byte (i.e. a tab character) in the source file. - One indentation level -> exactly one byte (i.e. a tab character) in the source file.
- Never use spaces to line up sequential lines: If you have run-on lines, indent as you would for a block.
b. Line widths: b. Line widths:
- Don't worry about having lines of code > 80-char wide. - Don't worry about having lines of code > 80-char wide.
- Lines of comments should be formatted according to ease of viewing, but simplicity is to be prefered over beauty. - Lines of comments should be formatted according to ease of viewing, but simplicity is to be prefered over beauty.
@ -17,10 +20,22 @@ j. Braces, when used, always have their own lines and are at same indentation le
(WRONG) (WRONG)
if( a==b[ i ] ) { printf ("Hello\n"); } if( a==b[ i ] ) { printf ("Hello\n"); }
foo->bar(someLongVariableName,
anotherLongVariableName,
anotherLongVariableName,
anotherLongVariableName,
anotherLongVariableName);
(RIGHT) (RIGHT)
if (a == b[i]) if (a == b[i])
printf("Hello\n"); // NOTE spaces used instead of tab here for clarify - first byte should be '\t'. printf("Hello\n"); // NOTE spaces used instead of tab here for clarity - first byte should be '\t'.
foo->bar(
someLongVariableName,
anotherLongVariableName,
anotherLongVariableName,
anotherLongVariableName,
anotherLongVariableName
);
@ -98,7 +113,7 @@ g. Never use a macro where adequate non-preprocessor C++ can be written.
h. Prefer "using NewType = OldType" to "typedef OldType NewType". h. Prefer "using NewType = OldType" to "typedef OldType NewType".
i. Make use of auto whenever type is clear or unimportant: i. Make use of auto whenever type is clear or unimportant:
- Always avoid doubly-stating the type. - Always avoid doubly-stating the type.
- Use to avoid vast and unimportant type declarations - Use to avoid vast and unimportant type declarations.
(WRONG) (WRONG)
@ -173,6 +188,7 @@ d. In general expressions should be roughly as important/semantically meaningful
a. Comments should be doxygen-compilable, using @notation rather than \notation. a. Comments should be doxygen-compilable, using @notation rather than \notation.
12. Include Headers 12. Include Headers
a. Includes should go in order of lower level (STL -> boost -> libdevcore -> libdevcrypto -> libethcore -> libethereum) to higher level. Lower levels are basically dependencies to the higher levels. For example: a. Includes should go in order of lower level (STL -> boost -> libdevcore -> libdevcrypto -> libethcore -> libethereum) to higher level. Lower levels are basically dependencies to the higher levels. For example:

3
alethzero/MainWin.h

@ -239,8 +239,7 @@ private:
/// Attempts to infer that @c _source contains Solidity code /// Attempts to infer that @c _source contains Solidity code
bool sourceIsSolidity(std::string const& _source); bool sourceIsSolidity(std::string const& _source);
/// @eturns all method hashes of a Solidity contract in a string /// @eturns all method hashes of a Solidity contract in a string
std::string const getFunctionHashes(dev::solidity::CompilerStack const &_compiler, std::string const getFunctionHashes(dev::solidity::CompilerStack const &_compiler, std::string const& _contractName = "");
std::string const& _contractName = "");
std::unique_ptr<Ui::Main> ui; std::unique_ptr<Ui::Main> ui;

Loading…
Cancel
Save