[TYPO3-50-general] Coding Guidelines: Rule for long criteria line breaks - Voting

Christopher Hlubek bruno.bolzano at gmail.com
Wed Sep 10 09:43:16 CEST 2008


I personally prefer number 2.

Of course complex statements should be avoided at first but aren't unavoidable.

The "operator after break" rule is fine for breaking strings over many
lines, too.

-Christopher

2008/8/29 Tim Eilers <tim.eilers at web.de>:
> Patrick-Emil Zörner schrieb:
>> Ahoj,
>>
>> 2008/8/28 Tim Eilers <tim.eilers at web.de>:
>>> Hi folks,
>>>
>>> while coding Sniffs and reading other people code i often jumped about
>>> long criterias which where breaked into several lines, which is conform
>>> to our currenct coding guideline rule:
>>>
>>> ----
>>> if (weHaveALotOfCriteria() &&
>>>   notEverythingFitsIntoOneLine() ||
>>>   youJustTendToLikeIt()) {
>>>      doThis();
>>> ----
>>>
>>> While this looks easy to read it can be very difficult in complex code.
>>> I would suggest to change the rule to this:
>>>
>>> ----
>>> if (weHaveALotOfCriteria()
>>>   && notEverythingFitsIntoOneLine()
>>>   || youJustTendToLikeIt()) {
>>>      doThis();
>>> ----
>>
>> Please read a smiley after each of my rather provocative sentences so
>> I do not need to make one after each sentence.
>
> True irony doesn't need smilys.
>
>>
>>> Advantage:
>>> You clearly can see, that the line belongs to a longer criteria.
>>
>> Can you?
>
> Ok, i should have added "when i begin to read the line". In the first
> solution you need to read some code until you notice that.
>
>>
>>> I am interested in your opinion, what do you think?
>>
>> Is this going to lead to a discussion tabs vs. spaces, 8 spaces vs. 4 spaces?
>
> Why not?
>
>>
>>> If all or many will agree, i would also do a Sniff, which checks it.
>>
>> What PHP really lacks is a tool like perltidy [1]. Whatever it does
>> you will know what it will look like in the end. So you can have your
>> own script running over the code when getting the source. And before
>> you check in your code you run "phptidy".
>
> That looks really nice. So we could add a project named FLOW3CGLFormatter.
>
> The problem is, that it has to be in the developers development
> environment. Since everyone could use any editor he wants that could be
> quiet difficult.
>
> By the way:
> perltidy formats long criteria like the second solution i suggested.
>
>>
>> greetings
>>
>> paddy
>>
>> 1. http://perltidy.sourceforge.net/
> _______________________________________________
> TYPO3-project-5_0-general mailing list
> TYPO3-project-5_0-general at lists.netfielders.de
> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-project-5_0-general


More information about the TYPO3-project-5_0-general mailing list