Is it possible to write good and understandable code without any comments?

前端 未结 20 1241
攒了一身酷
攒了一身酷 2020-12-28 18:35

Can any one suggest what is the best way to write good code that is understandable without a single line of comments?

20条回答
  •  生来不讨喜
    2020-12-28 18:57

    You usually can turn your comment into a function name something like:

    if (starColourIsGreaterThanThreshold(){
        doSomething(); 
    }
    
    ....
    
    private boolean starColourIsGreaterThanThreshold() { 
        return starColour.red > THRESHOLD && 
               starColour.blue > THRESHOLD && 
               starColour.green > THRESHOLD
    } 
    

提交回复
热议问题