 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Halbert" <hal### [at] gmail com> wrote in message
news:4863dbb4$1@news.povray.org...
> I, for one, find it much easier to read C++ code which is braced like
this:
>
> if(somecondition == 0)
> {
> if(somecondition == 0) {
> // do some stuff
Whereas I find the first far too spread out to be able to read easily and
use the second as my standard code layout in C-like languages
> Why doesn't the rest of the world understand that?
>
Because the rest of the world doesn't necessarily agree with you?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Gail Shaw <initialsurname@sentech sa dot com> wrote:
> Whereas I find the first far too spread out to be able to read easily
Compactness does not imply readability. On the contrary.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Warp" <war### [at] tag povray org> wrote in message
news:4863e7ae@news.povray.org...
> Gail Shaw <initialsurname@sentech sa dot com> wrote:
> > Whereas I find the first far too spread out to be able to read easily
>
> Compactness does not imply readability. On the contrary.
I never said it did.
I said that I find the first too spread out to read easily and that I prefer
the second as *I* personally find it easier to read.
If you prefer the former, more power to you. Just don't expect me to code
the same way.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
It's true that its only a preferance I personally have. The rest of the
world doesn't have to agree with me. I just like the way the braces all line
up and make visually clear the beginning and end of each code block. Its
easier for me to see than matching of the ending brace with the associated
expression at the top of the block.
I have been quietly living with that gripe in the back of my mind for the
last 18 or 19 years. Now that it's out in the open, I feel much better.
--
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Halbert" <hal### [at] gmail com> wrote in message
news:4863edeb$1@news.povray.org...
> It's true that its only a preferance I personally have. The rest of the
> world doesn't have to agree with me.
Everyone's entitled to their prefered way of doing things. Life would be
boring if we all agreed on everything
> I have been quietly living with that gripe in the back of my mind for the
> last 18 or 19 years. Now that it's out in the open, I feel much better.
Good.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Gail Shaw <initialsurname@sentech sa dot com> wrote:
> Life would be boring if we all agreed on everything
I disagree.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Halbert wrote:
> I, for one, find it much easier to read C++ code which is braced like this:
>
> if(somecondition == 0)
> {
> // do some stuff
> }
> else
> {
> // do something else
> }
I, for more than one, do not.
> As opposed to
>
> if(somecondition == 0) {
> // do some stuff
> }
> else {
> // do something else
> }
To me, the latter method is much more like POV-Ray than the first
method. I learned POV first, so I guess that's why I do it.
Since most of the code I write is never seen by another poor soul, you
won't find me bending backwards to tailor it for the "posh" crowd.
> Why doesn't the rest of the world understand that?
I kinda feel bad for the one guy who had to see my C++ code. At least it
was relatively short :)
Sam
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> Gail Shaw <initialsurname@sentech sa dot com> wrote:
>> Whereas I find the first far too spread out to be able to read easily
>
> Compactness does not imply readability. On the contrary.
>
Case in point:
n=(i<12&&j>=i)?(sqrt(z)*y+j):(y+j*i);
vs
if( i < 12 && j >= i )
{
n = sqrt(z) * y + j;
}
else
{
n = y + j * i;
}
;)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
stbenge wrote:
> Halbert wrote:
>> I, for one, find it much easier to read C++ code which is braced like
>> this:
>>
>> if(somecondition == 0)
>> {
>> // do some stuff
>> }
>> else
>> {
>> // do something else
>> }
>
> I, for more than one, do not.
>
>> As opposed to
>>
>> if(somecondition == 0) {
>> // do some stuff
>> }
>> else {
>> // do something else
>> }
>
> To me, the latter method is much more like POV-Ray than the first
> method. I learned POV first, so I guess that's why I do it.
>
I learned POV first, too. But for C/C++ code, the second example seems
foreign. I much prefer the first example.
But it's kind of like saying you prefer a room painted hunter green,
while I'd prefer forest green.
The only thing I'll say is that if there are coding standards in place,
follow the standard your organization uses.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Mike Raiford <mra### [at] hotmail com> wrote:
> Case in point:
> n=(i<12&&j>=i)?(sqrt(z)*y+j):(y+j*i);
Of course spaces could help readability a bit. Like:
n = (i < 12 && j >= i) ? (sqrt(z)*y + j) : (y + j*i);
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |