java - Indent group variable function call code convention -


i have habit of indenting group of function calls this:

list <dog> dogs = new arraylist<>();    dogs.add(new dog(1));    dogs.add(new dog(2));    dogs.add(new dog(3));    dogs.add(new dog(4));    dogs.add(new dog(5)); system.out.println("list of dogs: " + dogs); cat cat1 = new cat(1);    cat.meow();    cat.startsrunningfrom(dogs); dog d1 = dogs.get(1); d1.catches(cat1); 

are these bad practices in code convention, or these haven't being talked about? because i've tried find code conventions recommend such indentations on function calls variables/class.

for me, above code more readable without:

list<dog> dogs = new arraylist<>(); dogs.add(new dog(1)); dogs.add(new dog(2)); dogs.add(new dog(3)); dogs.add(new dog(4)); dogs.add(new dog(5)); system.out.println("list of dogs: " + dogs); cat cat1 = new cat(1); cat.meow(); cat.startsrunningfrom(dogs); dog d1 = dogs.get(1); d1.catches(cat1); 

the indentations me provide clear separation variable declarations , other function operations, following tightly related operations on variable.

can comment on why @ bad practice, or if it's acceptable outside of provided codes (outside of list operations).

are these bad practices in code convention, or these haven't being talked about?

well, depends! if working on open source have stick guidelines pretty much. there nothing bad/good unless peers fine it.

as matter of fact, people in team use code formatters , have set pre-defined rules comments , white-spaces etc. try follow same rules easy spot differences while merging code main repository.

the other thing that, i'm used of seeing accepted conventions below code snippet tricks me in assuming start , end of block.

list<dog> dogs = new arraylist<>(); ----> dogs.add(new dog(1));       dogs.add(new dog(2));       dogs.add(new dog(3));       dogs.add(new dog(4));       dogs.add(new dog(5)); <---- system.out.println("list of dogs: " + dogs); 

there no harm in using such conventions, said earlier, should accepted peers in environment working.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -