mardi 15 décembre 2015

IF ELSE coding style VS IF coding style

I have been referring my new company's code, where I found the code was not wrapped around IF and ELSE so was little bit confusing in flow. For example:

if(user_is_registered)
  {
      // You are already registered.
      //exit
  }
//New user's registration code goes here

While my last company was following the other way i.e. :

if(user_is_registered)
   {
      // You are already registered.
   }
else
   {
      //New user's registration code goes here
   }

Like every fresher I am confused which is the best practice to follow with legitimate reasons. Please enlighten me. I tried to find out answers for the same, but could not get. Please also suggest me other refs if available. Thank you.

Aucun commentaire:

Enregistrer un commentaire