New answers tagged

0 votes

Best style practice: avoid negation in conditionals?

After having worked for years with tons of C and C++ code where if(x) or if(!x) was used to test if a pointer or integer x was valid or not, I got used to this idiom and don't see a huge difference to ...
user avatar
  • 185k
7 votes

Should I use unnecessary function for readability sake

Possibly yes, but in this case no —- because your extra functions don’t make your code more readable. const renderNavBar = (size ==='small') ? renderMobileNavBar : renderDesktopNavBar; /* whatever*/ ...
user avatar
  • 10.4k
2 votes

Best style practice: avoid negation in conditionals?

Express the intent The driving principe should be to express intentions, i.e. what you really mean to achieve. This makes the code self-explanatory. Applying this principe to integer comparisons with ...
user avatar
  • 67.8k
14 votes
Accepted

Should I use unnecessary function for readability sake

We do a lot of things in programming just for the sake of readability - like giving variables meaningful names (instead of just naming them a, b, c, d, ...). Or specificially conditionals - there is a ...
user avatar
  • 185k

Top 50 recent answers are included