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

前端 未结 20 1418
攒了一身酷
攒了一身酷 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:58

    I like to 'humanise' code, so instead of:

    if (starColour.red > 200 && starColour.blue > 200 && starColour.green > 200){
       doSomething();
    }
    

    I'll do this:

    bool starIsBright;
    starIsBright = (starColour.red > 200 && starColour.blue > 200 && starColour.green > 200);
    
    if(starIsBright){
       doSomething();
    }
    

提交回复
热议问题