POV-Ray : Newsgroups : povray.off-topic : code readability Server Time
7 Sep 2024 19:12:46 EDT (-0400)
  code readability (Message 34 to 43 of 73)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Mike Raiford
Subject: Re: code readability
Date: 27 Jun 2008 10:29:01
Message: <4864f92d@news.povray.org>
Invisible wrote:

> is much more readable than
> 
>   t1 = y*y
>   t2 = y*t1
>   t3 = 2*t2
>   t4 = a*b
>   t5 = 3*t4
>   t6 = t3-t5
> 
> despite being much more compact. Counter-examples in the opposite 
> direction are not hard to find either.

Hey ... that looks familiar.

... I think someone here used to write code exactly like that! 0.o


Post a reply to this message

From: Mike Raiford
Subject: Re: code readability
Date: 27 Jun 2008 10:29:35
Message: <4864f94f$1@news.povray.org>
Stephen wrote:
> On Fri, 27 Jun 2008 01:26:58 +0300, Eero Ahonen
> <aer### [at] removethiszbxtnetinvalid> wrote:
> 
>> Warp wrote:
>>>   I disagree.
>>>
>> Good, 'cause you're wrong.
> 
> I can't help but agree with you.

I disagree.

Everyone's wrong!


Post a reply to this message

From: Mike Raiford
Subject: Re: code readability
Date: 27 Jun 2008 10:31:41
Message: <4864f9cd$1@news.povray.org>
Eero Ahonen wrote:
> Tim Nikias wrote:
>>
>> Heh, that reminds me... Some guy actually wrote code like this:
>>
> 
> Somehow those variables remind me of what I've decided I'll do at work 
> some day, when I'll have a place where it fits:
> 
> if (!successful) {
>     try_harder();
> }
> 
>> Regards,
>> Tim
> 
> 

try
{
    AcheiveYourGoals();
}
catch(DidntSucceedException ex)
{
   TryAgain();
}

:p


Post a reply to this message

From: Mike Raiford
Subject: Re: code readability
Date: 27 Jun 2008 10:33:58
Message: <4864fa56$1@news.povray.org>
stbenge wrote:

> If I worked for an organization, I would definitely change my style. Of 
> course if I were programming for a living, I would probably go to school 
> where they would teach me how to write code that people could decipher :)

Write code that others can decipher? Why would you do a thing like that? ;)

Everyone knows that if you code for a living, you code for job 
security... you wouldn't want the janitor to take your job, would you? :D

(Of course, I'm joking .... it doesn't work well in a team environment 
to code for job security)


Post a reply to this message

From: Mike Raiford
Subject: Re: code readability
Date: 27 Jun 2008 10:38:20
Message: <4864fb5c$1@news.povray.org>
Halbert wrote:
> How about Microsoft's engineers starting the whole Hungarian Notation 
> convention with Windows programing. (like lpstrFilePath or iRecursion, etc.) 
> There seems to be no set standard to it. While the intention is good,  a 
> beginner may have wonder why some variables have names like lpszDemung or 
> lpfnCBack.

There seems to be two standards, one which describes type: lpszString 
and one that defines function (sort of): instead of iOptions, it's fOptions.

You don't know how many times I've looked at a function signature, and 
seen fSomething on something that should receive bits and wondered why 
the hell they want a float, only to look a bit to the left and see that 
it is indeed an integer.


Post a reply to this message

From: Invisible
Subject: Re: code readability
Date: 27 Jun 2008 10:39:56
Message: <4864fbbc$1@news.povray.org>
Mike Raiford wrote:

> try
> {
>    AcheiveYourGoals();
> }
> catch(DidntSucceedException ex)
> {
>   TryAgain();
> }


try
{
   AchieveYourGoals();
}
catch (Failure e)
{
   CallAirStrike();
}

// With appologies for Murphy...

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Eero Ahonen
Subject: Re: code readability
Date: 27 Jun 2008 11:34:04
Message: <4865086c$1@news.povray.org>
Mike Raiford wrote:
> 
> try
> {
>    AcheiveYourGoals();
> }
> catch(DidntSucceedException ex)
> {
>   TryAgain();
> }
> 
> :p

Would be great, too :). The thing about my code is that at work we have 
this department-wide habit that if someone says "this doesn't work" or 
"I can't do this" oslt, the first answer is usually "try harder".

-- 
Eero "Aero" Ahonen
    http://www.zbxt.net
       aer### [at] removethiszbxtnetinvalid


Post a reply to this message

From: Warp
Subject: Re: code readability
Date: 27 Jun 2008 11:41:11
Message: <48650a17@news.povray.org>
Invisible <voi### [at] devnull> wrote:
> I'd say that there is only a fairly weak correlation (positive or 
> negative) between compactness and readability.

>    x = 2*y*y*y - 3*a*b

  The context was really a multilined program source code, not a
mathematical formula, which your line really is.

  Mathematical formulae can often be written compactly because they
a) aren't really program code, and b) there's an established syntax
to write it compactly.

-- 
                                                          - Warp


Post a reply to this message

From: Invisible
Subject: Re: code readability
Date: 27 Jun 2008 11:50:16
Message: <48650c38$1@news.povray.org>
Warp wrote:

>   The context was really a multilined program source code, not a
> mathematical formula, which your line really is.
> 
>   Mathematical formulae can often be written compactly because they
> a) aren't really program code, and b) there's an established syntax
> to write it compactly.

Perhaps you forget, the very word "computer" means "device for 
performing mathematical calculations". ;-)

Having programmed with Haskell for a while now, I would contest the 
"programs aren't mathematics" assertion. Having played with mathematics 
for even longer, I would contest the "established syntax" assertion too! 
[Rather, there are several incompatible and variously ambiguous syntaxes 
for writing any particular mathematical construct...]

Regardless, I would assert that how "readable" something is depends on 
how well it maps to your underlying mental processes - which is rather 
independant of the compactness or otherwise of the code. ;-)

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Invisible
Subject: Re: code readability
Date: 27 Jun 2008 11:52:31
Message: <48650cbf$1@news.povray.org>
Mike Raiford wrote:

> Hey ... that looks familiar.
> 
> ... I think someone here used to write code exactly like that! 0.o

It's certainly what the compiler transforms your code into - this is 
what machines derived from the design of Turing expect. But it is not 
necessarily how humans think. ;-)

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

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

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