Patch - move model related code from MainWindow and adjustments.

Dirk Hohndel dirk at hohndel.org
Mon Apr 22 11:10:06 PDT 2013


Thiago Macieira <thiago at macieira.org> writes:

> On segunda-feira, 22 de abril de 2013 09.43.51, Dirk Hohndel wrote:
>> Tomaz,
>> 
>> I know this is the style common in Qt and in many C++ apps... to the C
>> programer's eye this is really not nice...
>> 
>> -MainWindow::MainWindow() : ui(new Ui::MainWindow())
>> +MainWindow::MainWindow()
>> +: ui(new Ui::MainWindow())
>> +, model(new DiveTripModel(this))
>> 
>> we don't start lines with operators - we end lines with operators. 
>
> I don't like it either. It's meant to minimise the diff when adding a member at 
> the end (by avoiding the need to add a comma), but I find it really ugly.

At least that explains WHY this has become the standard. Thanks.

>> So
>> please keep the first parent class on the same line as the derived class
>> and when putting additional classes on a new line, have the comma on the
>> previous line and indent the class name with tabs and then spaces to line
>> them up:
>> 
>> MainWindow::MainWindow() : ui(new Ui::MainWindow()),
>>                            model(new DiveTripModel(this))
>> 
>> You may disagree, but I find this much easier to read
>
> I personally prefer ending the constructor line with the colon (:) and use a 
> plain one-level indentation on the next line. There's no alignment.
>
> That is:
> MainWindow::MainWindow() : 
> 	ui(new Ui::MainWindow()),
> 	model(new DiveTripModel(this))

That may be even better than what I proposed. Unless there are others
who hate it (and so far everyone from the Qt side has been remarkably
easy going with us and our (mostly my) code formatting requests) then
this could be something we should standardize on. 

> Out of curiosity, do you prefer:
>
> 	if (this &&
> 	    that)
> or
> 	if (this
> 	    && that)
>
> I guess the former, which is my preference too.

Definitely the former. This tells you clearly that there is more to come
and how it is connected.

/D


More information about the subsurface mailing list