Vertical alignment Programming style



with:



the latter example makes 2 things intuitively clear not clear in former:



the search , replace terms related , match up: not discrete variables;
there 1 more search term there replacement terms. if bug, more spotted.

however, note there arguments against vertical alignment:



inter-line false dependencies; tabular formatting creates dependencies across lines. example, if identifier long name added tabular layout, column width may have increased accommodate it. forces bigger change source code necessary, , essential change may lost in noise. detrimental revision control inspecting differences between versions essential.
brittleness; if programmer not neatly format table when making change, maybe legitimately previous point in mind, result becomes mess deteriorates further such changes. simple refactoring operations, such search-and-replace, may break formatting.
resistance modification; tabular formatting requires more effort maintain. may put off programmer making beneficial change, such adding, correcting or improving name of identifier, because mess formatting.
reliance on mono-spaced font; tabular formatting assumes editor uses fixed-width font. many modern code editors support proportional fonts, , programmer may prefer use proportional font readability.
tool dependence; of effort of maintaining alignment can alleviated tools (e.g. source code editor supports elastic tabstops), although creates reliance on such tools.

for example, if simple refactoring operation performed on code above, renaming variables $replacement $r , $anothervalue $a , resulting code this:



the original sequential formatting still fine after such change:








Comments

Popular posts from this blog

Journals by countries Pedophile press

The Story Of Sugriva Sugriva

History Thames Ironworks and Shipbuilding Company