`
samjavaeye
  • 浏览: 187609 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Line Length

 
阅读更多
【原因分析】
代码行长度过长,缺省限度为80字符,不区分中英文。
 
【影响分析】
尽量避免一行的长度超过80个字符,因为很多终端和工具不能很好处理。
 
【修改建议】
当一个表达式无法容纳在一行内时,可以依据如下一般规则断开:
  • 在一个逗号后面断开
  • 在一个操作符前面断开
  • 宁可选择较高级别(higher-level)的断开,而非较低级别(lower-level)的断开
  • 新的一行应该与上一行同一级别表达式的开头处对齐
  • 如果以上规则导致你的代码混乱或者使你的代码都堆挤在右边,那就代之以缩进8个空格。
以下是断开方法调用的一些例子:
someMethod(longExpression1, longExpression2, longExpression3,
                longExpression4, longExpression5);
var = someMethod1(longExpression1,
             someMethod2(longExpression2,
                          longExpression3));
  
以下是两个断开算术表达式的例子。前者更好,因为断开处位于括号表达式的外边,这是个较高级别的断开。
  longName1 = longName2 * (longName3 + longName4 - longName5)
              + 4 * longname6; //PREFFER
  longName1 = longName2 * (longName3 + longName4
                           - longName5) + 4 * longname6; //AVOID
分享到:
评论

相关推荐

    Transmission line length formula for coaxial cable to an antenna.zip

    Transmission line length formula for coaxial cable to an antenna.zip

    line-length.js:获取字符串的行长

    lineLength ( 'aaaaaaaa\naaaaaaaaaaaaaaaaaaaa\r\naaaaaa\n' ) ; //=> [8, 20, 6, 0] 安装 包管理器 npm install line-length bower install line-length const lineLength = require ( 'shinnn/line-length.js...

    linelengthicator:为您的文本找到最佳的行长。 复制、粘贴并让 Line Length-icator 完成剩下的工作

    线长符号我总是试图为我的段落、标题和其他文本找到最佳的行长。 我构建了 Line Length-icator 以避免手动计算字符(woof)。 !

    NSData+AESCrypt库

    - (NSString *)base64EncodingWithLineLength:(NSUInteger)lineLength; - (BOOL)hasPrefixBytes:(const void *)prefix length:(NSUInteger)length; - (BOOL)hasSuffixBytes:(const void *)suffix length:...

    摄像头 gc2385 代码 调试

    mtk6739平台gc2385像头调试代码

    NSData+AESCrypt

    - (NSString *)base64EncodingWithLineLength:(NSUInteger)lineLength; - (BOOL)hasPrefixBytes:(const void *)prefix length:(NSUInteger)length; - (BOOL)hasSuffixBytes:(const void *)suffix length:...

    vb 屏001幕取词程序

    Public Const EM_LINELENGTH = &HC1 Declare Sub RtlMoveOptiMemory Lib "KERNEL32" (lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long) Declare Function SendMessage Lib "user32" Alias "SendMessageA" ...

    三星S3C2440芯片手册

    This user’s manual describes SAMSUNG's S3C2440A 16/32-bit RISC microprocessor. SAMSUNG’s S3C2440A is ...separate 16KB instruction and 16KB data caches, each with an 8-word line length.

    s3c2451 manual

    This user’s manual describes SAMSUNG's S3C2451 16/32-bit RISC microprocessor. SAMSUNG’s S3C2451 is ...with separate 16KB instruction and 16KB data caches, each with an 8-word line length.

    Java语言编码规范

    4.1 行长度(LINE LENGTH) 6 4.2 换行(WRAPPING LINES) 6 5 注释(COMMENTS) 8 5.1 实现注释的格式(IMPLEMENTATION COMMENT FORMATS) 9 5.1.1 块注释(Block Comments) 9 5.1.2 单行注释(Single-Line Comments) 10 ...

    SCS2440 用户手册

    separate 16KB instruction and 16KB data caches, each with an 8-word line length. By providing a complete set of common system peripherals, the S3C2440A minimizes overall system costs and eliminates ...

    s3c2440英文手册

    separate 16KB instruction and 16KB data caches, each with an 8-word line length. By providing a complete set of common system peripherals, the S3C2440A minimizes overall system costs and eliminates ...

    雷达技术知识

    device such as a total station or theodolite in combination with a stadia rod or drop line to measure water surface elevations (Harrelson, et ai., 1994, Western et ai., 1997). Inaccuracies in ...

    nvidia-htop:一种丰富nvidia-smi输出的工具

    英伟达-htop 用于丰富nvidia-smi输出的工具。 安装 pip3 install nvidia-htop... -l|--command-length [length] Print longer part of the commandline. If `length' is provided, use it as the commandline length,

    Google C++ Style Guide(Google C++编程规范)高清PDF

    Formatting Line Length Non-ASCII Characters Spaces vs. Tabs Function Declarations and Definitions Function Calls Conditionals Loops and Switch Statements Pointer and Reference Expressions Boolean ...

    Total.Commander.v7.55.RC2.Multilingual.WinALL.Cracked-BLiZZARD

    - Command line for starting of programs with parameters, simply 捋? 圹? by typing the program name or by pressing CTRL+ENTER or 捋? 圹? CTRL+SHIFT+ENTER. 捋? 圹? - Configurable button bar and ...

    arcview 指导书

    在Network Analyst中,缺省使用线的长度<line length>来计算两地的最短路径。 从Working Unit下拉列表中选择工作单位,工作单位确定了该路线的总的费用,例如:在该路线上行驶所需的时间或距离。如果用<line length>...

    dm365_resizer.rar_The Various

    This function calculates the line length of various image planes at the input and output.

    lavender:Python稍有妥协的Python代码格式化程序

    行长度的Vim插件配置变量名为g:lavender_line_length而不是g:lavender_linelength ,以与其他配置变量名称保持一致。 文献资料 在上阅读,但在您的头上用lavender代替black 。 发展 建议使用来管理Python开发工具。...

Global site tag (gtag.js) - Google Analytics