2012/7/19 Rafael Dohms <lis...@rafaeldohms.com.br>

> On Thu, Jul 19, 2012 at 12:03 PM, Charlie Somerville <
> char...@charliesomerville.com> wrote:
>
> > This has code readability problem written all over it. When maintaining
> it
> > also has problems, like with the bracket-less if's.
> > You would need to add brackets if you add an extra line here, as well as
> > you might get unexpected behaviour of you forget to
> > add brackets in that case.
> >
> > I've often heard people make this argument, but I've never found it to be
> > a real concern in practise.
> >
> > Is this really such a common problem?
> >
>
> I have seen this problem happen, people losing time trying to figure out
> what is wrong only to find
> its a missing bracket.
> As Paul said, this is bug-prone.
>

Just curious (once more): How can anyone overlook, that the brackets are
intentionally omitted here?

if ($x) {
    // Do something
} else return null;


Of course it's a matter of code style [1], but one can write the ugliest
code with every syntax. This argument about "bug-prone" often confuses me,
because I for myself never had such a problem. I also never knew someone,
who had a problem with bracket-less blocks (but must say, that most write
blocks _with_ brackets, thus they _may_ have problems). I've often just
heard this "its bug-prone" (that sounds to me like "there are inattentive
devs out there" to me :X) as as killer argument...
At the end of the day I don't really care wether I should avoid
bracket-less blocks, or not, but ... it's this argument that annoys me :X
And I just think this just looks cute :)

try $calculator->calculateSomeVeryDifficultStuff() catch ($e) {
  // on failure
}

2cent and so on

Regards,
Sebastian


[1] I would wrap "return null;" in brackets too, if the line gets too long.

if ($x) {
    // Do something
} else {
    return someVeryLongStatement() && andSuch();
}






> --
> Rafael Dohms
> PHP Evangelist and Community Leader
> http://www.rafaeldohms.com.br
> http://www.phpsp.org.br
>

Reply via email to