Thread: If statements
View Single Post
Old 09-17-2002, 09:22 PM   #2 (permalink)
technobard
Centurion Nova Prime
 
technobard's Avatar
 
Join Date: May 2002
Location: Oak Park, IL (USA)
Posts: 287
technobard is on a distinguished road
Personally, I prefer the if/else structure. It's clearer (not that the other one is a stretch). It makes a bigger difference on a method that returns something. For example:

Code:
public boolean checkit () {
   boolean stat = false;

   if (abc) {
      doSomething(x);
      stat = true;
   } else {
      doSomething(y);
      stat = false;  //the default, so not really necessary
   }

   return stat;
}
Opinions will probably vary on this one, but I like having a single return where possible. (Although I'm sure I've violated this in some of my code).
technobard is offline   Reply With Quote