D pullrequest review process rant

H. S. Teoh hsteoh at quickfur.ath.cx
Thu May 9 10:35:58 PDT 2013


On Thu, May 09, 2013 at 07:22:28PM +0200, deadalnix wrote:
> On Thursday, 9 May 2013 at 17:02:29 UTC, Sean Kelly wrote:
> >On Thursday, 9 May 2013 at 10:19:16 UTC, Joseph Rushton Wakeling
> >wrote:
> >>
> >>Don't know quite why, but I wound up quite liking the rule that
> >>Linus Torvalds suggested, which I think comes from K&R --
> >>separate-line { for the opening of a function, same-line { for if(),
> >>while() statements and so on.
> >
> >Here's a breakdown of some of the more popular formatting styles:
> >http://en.wikipedia.org/wiki/Indent_style.  I think D tends towards
> >Allman style (which I think the astyle formatter calls BSD style).
> >My code is formatted a bit differently in terms of spacing around
> >parens but I'd be happy to have it changed--I use Allman style these
> >days too.
> 
> Actual style mostly don't matter. Consistency matter.

+1. One of the things I learned in my current day job is to follow
whatever style is in effect in the source you're modifying. As Andrei
said in TDPL, even if it's not your personal preference, you won't turn
into a goblin just for following whatever style is already there.

I've seen too many code changes that *don't* follow the prevalent style
in a particular source: they are a perennial source of bugs and other
problems, because it's very jarring to read a source that suddenly
switches style for 5-6 lines or so, and then switches back. It distracts
one from following the flow of the code, leading to oversights and
hidden unnoticed bugs. Worse yet, people sometimes make changes with
different default editor settings on tab stops, so what looks OK to them
shows up as very jarring wrong indentations -- this is why I've come to
understand why tabs are Teh Evil (nobody ever agrees on what they should
be, and everyone contributes code using different tab stop settings that
causes a gigantic mess in any project with non-trivial numbers of
contributors). But the absolute worst is when everybody just follows
their own style when editing source code -- the result is a chimeraic
monstrosity where the coding style changes every 5 lines, and nobody can
understand what the code does (and nobody dares fix the formatting 'cos
then their name would show up in `svn blame`, and nobody wants to take
responsibility for those malformatted lines of code that in all
likelihood are crawling with bugs).


T

-- 
Skill without imagination is craftsmanship and gives us many useful objects such as wickerwork picnic baskets.  Imagination without skill gives us modern art. -- Tom Stoppard


More information about the Digitalmars-d mailing list