Re: CS discussion
| From: | Greg Beaver | Date: | Mon, 28 Jul 2003 20:12:20 +0000 |
| Subject: | Re: CS discussion | ||
| References: | 1 2 3 | Groups: | php.pear.qa |
| Request: | Send a blank email to pear-qa+get-73@lists.php.net to get a copy of this message | ||
Hello everyone,
I think a much more important discussion than how to break is where to break lines. I propose line breaks between 75 and 80 characters.
What is the main problem created by line breaks? I think it is in debugging a situation where there is a missing bracket. PHP is not very good at determining where you forgot to put a start or end bracket, and it should be easy to visually tell, without having to do any eyeball acrobatics.
In the past, I used to code like so:
if (blah)
{
for(;;)
{
}
}
because the { and } line up, but now that I'm forcing myself to use PEAR CS in PEAR projects, I go
if (blah) {
for(;;) {
}
}
This means that I am visually matching up the if with the } and the for with the }. Any proposal that puts code on the same level as the indentation is confusing.
if (blah ||
blah2)
for(;;) {
}
}
My eye sees "blah2" as the start of the code block, so if I move things around, half the time I grab the blah2 as well, killing the code. This is why I prefer:
if (blah ||
blah2) {
for(;;) {
}
}
or
if (blah
|| blah2) {
for(;;) {
}
}
a half-indent is very nice, because it makes the question of where to put the operator irrelevant. Either way, it looks like a continuation because it visually breaks the normal expectation of control blocks, but in a regulated way.
I would suggest mandating the indentation, and not being draconian about which end the operator goes on. Everyone here is violently in favor of their own way, why make half the developers unhappy when neither solution solves the problem caused by line breaks in the first place?
Regards,
Greg