21 if (foo == otherFoo)
22 {
23 return true;
24 }
25 else
26 {
27 return false;
28 }
The above is an example of what not to do. There have been many times in my life where I have done this not thinking about what I was doing. I am glad to say that time has passed. I have talked to others about it and they say they do it because it is more explicit and easier to read. I have a hard time agreeing with this stance how can the above be easier to read then the following.
21 return foo == otherFoo;
It’s short simple and easy to read.
2 comments:
Good thinking. This actually reduces the amount of assembly to 2 assembly lines. Compare and return. Nice!
That is seks and my biggest pet peeve of any dev I've ever met. Anytime a boolean state can be inferred is always preferable as it also reduces the amount of error that can happen and as Trixtur says it does reduce code. Great phoast m8.
Post a Comment