Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Friday, April 27, 2012

Good practice when naming a Boolean variable/Property

schema_boolean<soapbox>

When defining a Boolean (true/false) variable or property

  1. Prefix the name with "Is" or "Has"
  2. Do not negate in your variable name.

Bad Boolean variables names:

  • Allowed (No prefix)
  • IsNonUser (Negated Name)
  • IsNotAllowed (Negated Name)
  • Permission (No prefix)

Good boolean variable names:

  • IsAllowed
  • IsUser
  • IsAllowed
  • HasPermission

Why?

Because if statements with negation become easier to read.

I think this if statement is harder to read

   1: if(!IsNotAllowed) 
   2: { 
   3:     ShareCandy(); // "If not is not allowed then share candy"
   4: } 

Then this if statement

   1: if(IsAllowed) 
   2: { 
   3:     ShareCandy(); // "If is allowed then share candy"
   4: } 

</soapbox>

Wednesday, December 10, 2008

Where can I download old versions of JetBrains' ReShaper?

Often times I've tried to find old version of JetBrain's amazing tool ReSharper (R#). Usually I have to settle with some download site. Which makes me feel a little uneasy. The other day I found the JetBrains' provided link. So I figured I would share with the world. http://www.jetbrains.net/devnet/docs/DOC-280;jsessionid=3B8C7B3BA56CA355357DE8E5437485E9