POV-Ray : Newsgroups : povray.off-topic : code readability Server Time
8 Sep 2024 01:17:11 EDT (-0400)
  code readability (Message 4 to 13 of 73)  
<<< Previous 3 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Gail Shaw
Subject: Re: code readability
Date: 26 Jun 2008 14:40:07
Message: <4863e287@news.povray.org>
"Halbert" <hal### [at] gmailcom> 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

From: Warp
Subject: Re: code readability
Date: 26 Jun 2008 15:02:06
Message: <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.

-- 
                                                          - Warp


Post a reply to this message

From: Gail Shaw
Subject: Re: code readability
Date: 26 Jun 2008 15:14:12
Message: <4863ea84@news.povray.org>
"Warp" <war### [at] tagpovrayorg> 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

From: Halbert
Subject: Re: code readability
Date: 26 Jun 2008 15:28:43
Message: <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. 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

From: Gail Shaw
Subject: Re: code readability
Date: 26 Jun 2008 15:39:00
Message: <4863f054@news.povray.org>
"Halbert" <hal### [at] gmailcom> 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

From: Warp
Subject: Re: code readability
Date: 26 Jun 2008 15:41:01
Message: <4863f0cd@news.povray.org>
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

From: stbenge
Subject: Re: code readability
Date: 26 Jun 2008 15:47:59
Message: <4863f26f@news.povray.org>
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

From: Mike Raiford
Subject: Re: code readability
Date: 26 Jun 2008 15:53:34
Message: <4863f3be@news.povray.org>
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

From: Mike Raiford
Subject: Re: code readability
Date: 26 Jun 2008 15:56:34
Message: <4863f472$1@news.povray.org>
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

From: Warp
Subject: Re: code readability
Date: 26 Jun 2008 15:57:01
Message: <4863f48d@news.povray.org>
Mike Raiford <mra### [at] hotmailcom> 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

<<< Previous 3 Messages Goto Latest 10 Messages Next 10 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.