Google C++ Style Guideuse as possible. This makes it easier for the reader to find the declaration and see what type the variable is and what it was initialized to. In particular, initialization should be used instead of declaration scopes. E.g.: while (const char* p = strchr(str, '/')) str = p + 1; There is one caveat: if the variable is an object, its constructor is invoked every time it enters scope and is created, and its destructor dtor get called 1000000 times each. f.DoSomething(i); } It may be more efficient to declare such a variable used in a loop outside that loop: Foo f; // My ctor and dtor get called once each. for (int i =0 码力 | 83 页 | 238.71 KB | 1 年前3
Google Python Style Guideterms of performance, allowing properties bypasses needing trivial accessor methods when a direct variable access is reasonable. This also allows accessor methods to be added in the future without breaking testing whether a variable or argument that defaults to None was set to some other value. The other value might be a value that’s false in a boolean context! • Never compare a boolean variable to False using Python function can refer to variables defined in enclosing functions, but can not assign to them. Variable bindings are resolved using lexical scoping, that is, based on the static program text. Any assignment0 码力 | 30 页 | 94.81 KB | 1 年前3
Google Java Style Guidecolumn limit may be line-wrapped at the author’s discretion. 6 Tip: Extracting a method or local variable may solve the problem without the need to line-wrap. 4.5.1 Where to break The prime directive parallel elements. Section 4.6.3 on Horizontal alignment addresses the discouraged practice of using a variable number of spaces to align certain tokens with previous lines. 4.6 Whitespace 4.6.1 Vertical Whitespace end-of-line comment. Here, multiple spaces are allowed, but not required. 7. Between the type and variable of a declaration: Listlist 8. Optional just inside both braces of an array initializer 0 码力 | 19 页 | 84.76 KB | 1 年前3
Google's R Style Guideentire R user community at Google. Summary: R Style Rules 1. File Names: end in .R 2. Identifiers: variable.name (or variableName), FunctionName, kConstantName 3. Line Length: maximum 80 characters 4. Indentation: according to the following conventions. The preferred form for variable names is all lower case letters and words separated with dots (variable.name), but variableName is also accepted; function names have letters and no dots (FunctionName); constants are named like functions but with an initial k. • variable.name is preferred, variableName is accepted GOOD: avg.clicks OK: avgClicks BAD: avg_Clicks • FunctionName0 码力 | 8 页 | 47.42 KB | 1 年前3
共 4 条
- 1













