But let me clarify...
Hmmmm.... four rewrites and I still can't make my point clearly. Let me put it this way... in real-world programs, 'if (x && y)' *clearly* illustrates the original programmer's intention that 'action' is dependant on the two conditions. The conditional statement has been written for the explicit purpose of executing the action. 'if (x) if (y)' conveys a different meaning... that action is dependent on two separate conditions and the conditonal statements(s) were written, potentially, for more work than executing the action.
Yes, if a second programmer wants to diddle with the '&&' version, s/he can, but ... at least s/he will have had to recognize that there may have been method to the original madness.
As for efficiency, yes, there are cases where efficiency matters. For the most part, as you agreed, it doesn't. The best approach to writing code, imosho, is to write *maintainable* code first. Then, if benchmark testing indicates that efficiency of a given set of operations needs to be improved, target that specific area and optimize the heck out of it. |