Formatting multiple arguments passed to a function in Java

后端 未结 6 1017
广开言路
广开言路 2021-02-13 21:18

Often the number of arguments passed to a function can be large. Consider the following case:

calculate(dataManager.getLastUpdate().getNumberOfChildren(),
               


        
6条回答
  •  梦毁少年i
    2021-02-13 21:45

    I wholeheartedly agree with your example of having one argument per line, all lined up under each other.

    It makes it very easy to scan down the list to see what is there or what is missing.

    It also makes it easier to document null values as being "// user id" or something similar.

    I find it's particularly easy to visually parse, rather than having several long lines of densely packed values that may often look alike.

提交回复
热议问题