Write less code

If you find yourself writing a lot of code to do something simple, you’re probably doing it wrong. A good example is the lowly boolean:

if (numMines > 0)
{
   enabled=true;
}
else
{
   enabled=false;
}

 When you could just write: 

enabled = numMines > 0;


The less code you write the better. Less to debug, less to refactor, less to go wrong. Use with moderation; readability is just as important, you don’t want to make your code less readable by doing this. 

10 steps to becoming a better programmer


posted @ 2013-12-09 21:07  一个学渣  阅读(237)  评论(0编辑  收藏  举报

 

CSDNGitHub 联系邮箱:aikongmeng@gmail.com


Copyright 2008-2019 Government All Rights Reserved