ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[TOC] ## 用布尔变量对程序加以文档说明 bad ``` if( (elementIndex<0) || (MAX_ELEMENTS<elementIndex) || (elementIndex ==lastElementIndex) ){ ... } ``` good ``` finished =(elementIndex<0) || (MAX_ELEMENTS<elementIndex) ; repeatedEntry = (elementIndex ==lastElementIndex); if(finished|| repeateEntry){ ... } ``` ## 用布尔变量来简化复杂问题的判断 bad ``` If ((document.AtEndOfStream()) And (Not inputError) ) AND ((MIN_LINES <=lineCount) And (lineCount <=MAX_LINES)) And (Not ErrorProcessing()) Then 'do someting or other End If ``` good ``` allDateRead = (document.AtEndOfStream()) And (Not inputError) legalLineCount = (MIN_LINES <=lineCount) And (lineCount <=MAX_LINES) If (allDateRead ) AND (legalLineCount) And (Not ErrorProcessing()) Then 'do someting or other End If ```