[TYPO3-50-general] Coding Guidelines: Rule for long criteria line breaks - Voting
Mathias Bolt Lesniak, liliO Design
mathias at lilio.com
Fri Aug 29 19:17:25 CEST 2008
Hi!
I'd vote for the second one, like Tim. That's how I usually do it. But
complex code makes anything hard to read.
In case 1: If you don't wrap the lines in your editor the && and ||
may end up too far right, outside of the window. That's pretty
illegible.
In case 2: && and || would always be visible, and you'd have to have a
VERY narrow window for that to cause any problem even in very deep
nesting situations.
PS! I prefer my tabs to be 4 spaces wide... But if I put function
arguments or if clauses on multiple lines I indent the arguments/
clauses with 2 spaces. Between words I use 1 space. ;-)
Best wishes
Mathias Bolt Lesniak
LiliO Design - www.lilio.com
mathias at lilio.com
On 29. Aug 2008, at 17:29, Patrick-Emil Zörner wrote:
> 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:
Case 1:
>>
>>
>> ----
>> 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:
>>
Case 2:
>> ----
>> 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.
>
>> Advantage:
>> You clearly can see, that the line belongs to a longer criteria.
>
> Can you?
>
>> 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?
>
>> 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".
>
> 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