I have this habit of indenting a group of function calls like 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 really a bad practices in a code convention, or these haven't really being talked about? Because I've tried to find some code conventions that would recommend such indentations on function calls from certain variables/class.
For me, the above code is much more readable than 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 for me provide a clear separation from variable declarations and other function operations, with the following tightly related operations on the variable.
Can anybody comment on why at all this is a bad practice, or if it's generally acceptable outside of the provided codes (outside of a List operations).