+ 1
Putting brackets in a clearer position
Is there a reason for everyone to code using the brackets isolated in different lines? I find them so much easier to be visualized if written as follows. is it not a good practice? public class Program {public static void main(String[] args) {int age = 25; if(age <= 0) {System.out.println("Error");} else {System.out.println("Really?");}}}
5 Answers
+ 8
Well⊠I do it to keep my code clear/readable⊠maybe that's the reason?âŠ
+ 5
the usual practices are either
function(){
indented code here
}
or
function()
{
indented code here
}
+ 4
Adopting a layout consistent throughout all project files (and preferably supported be editors automatic layout) facilitates reviews and so avoid some errors.
+ 4
I have always wondered why this:
function(){
}
when this is so much more symmetrical:
function()
{
}
+ 2
There's lots of indent styles, and yours is actually LISP-style! https://en.wikipedia.org/wiki/Indent_style#Lisp_style
But yeah nobody does it that way outside of LISP so I wouldn't do it unless you want to be beaten up by other programmers.