coding style - Is it bad practice to use an if-statement without brackets? -


I have seen such a code:

  If (statement) does this; And do this;  

I do not like it, I think this cleaner is more readable

  if (statement) {do this; } And (do this); }  

Is this a matter of preference or will it be recommended in any other way?

The problem with the first version is that if you go back and remember without adding curl braces. If without adding a second statement to other sections, your code will break into an unexpected and entertaining manner.

EDIT: Nedee explains it in the comment, but it is worth the inclusion here, too, I think. This is not just a description of some ivory-tower:


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -