Skip to main content
2 of 3
added 24 characters in body
Doc Brown
  • 220.3k
  • 35
  • 410
  • 623

I think most of us will agree there is no "perfect solution" to the described issue of readability vs. changing indentation in context of renaming, so let me focus on the answerable part of this question, the terminology.

What we see here are different kinds of multi-part statements, which we want to layout as multi-line blocks. This leads to the effect of vertically coupled alignment.

(I would not call this "vertical coupling", exactly for the reasons mentioned by Filip Milovanović in a comment: this term can be confused with it's meaning in regards to components and layers).

Now, there are two main kind of layout styles for multi-line blocks, both are described in Steve McConnell's classic book "Code complete (1st edition)" in chapter 18.3 ("Layout Styles"):

  • Endline Layout (as in the initial examples of the question)

  • Pure Blocks (as in the reformatted version of the examples)

When using "Endline Layout", the vertically coupled alignment leads to the necessity of changing indentation in case of renaming. Pure Blocks avoid this.

A little bit later in chapter 18.3, McConnell wrote:

In short, avoid endline layout because it's inaccurate, it's hard to apply consistently, and it's hard to maintain.

To be fair, at this point of the book, McConnell had blocks of multiple statements in mind, with some kind of begin/end brackets. Later, in chapter 18.5 ("Laying Out Individual Statements"), he presented different forms of indentation for routine-call continuation lines, either

  • by using standard indentation, or
  • by aligning under the first argument of the routine, or
  • by using one individual line per argument - including the first.

And to cite him finally about these layouts:

Any of the three options for formatting multiple-line routine calls works all right, if you use it consistently.

Doc Brown
  • 220.3k
  • 35
  • 410
  • 623