+ 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?");}}}

14th Jan 2017, 12:06 PM
Yuri Disaró Amado
Yuri Disaró Amado - avatar
5 Respuestas
+ 8
Well… I do it to keep my code clear/readable… maybe that's the reason?…
14th Jan 2017, 12:08 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 5
the usual practices are either function(){ indented code here } or function() { indented code here }
14th Jan 2017, 12:14 PM
ifl
ifl - avatar
+ 4
Adopting a layout consistent throughout all project files (and preferably supported be editors automatic layout) facilitates reviews and so avoid some errors.
14th Jan 2017, 12:19 PM
ifl
ifl - avatar
+ 4
I have always wondered why this: function(){ } when this is so much more symmetrical: function() { }
14th Jan 2017, 12:50 PM
Karl T.
Karl T. - avatar
+ 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.
14th Jan 2017, 12:50 PM
Schindlabua
Schindlabua - avatar