swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Clever code vs. readable code...


From: Scott Christley
Subject: Re: Clever code vs. readable code...
Date: Tue, 11 Nov 1997 12:30:36 -0800

Pinch myself for getting into these philosophical arguments, but really that
"unreadable" code is actually kind of readable :-)  and yes Brad your
interpretation is correct.

I wonder if its the excessive number of brackets "[]" that makes code like
this difficult to immediately grasp.  I've heard somewhere that normal
people can only unconsiously "count" at most about 5 objects, any more than
that and the person has to consciously recognize the individual objects to
generate a count; I would think the same phenomenon occurs when viewing
nested statements.

I agree with you though Brad; I would write the code out as individual
statements like you have.  That is one of the really nice things about ObjC
as well because the actual amount of typing between the "unreadable" code
and Brad's interpretation is minimal, so minimal that the self documenting
nature of the other code more than makes up for the few extra keystrokes.

cheers
Scott

ps: I don't know exactly what -getNodeList does but I would presume that it
returns a complete list of the nodes that have been -addNode:'ed to theFNet.


At 01:03 PM 11/11/97 -0500, address@hidden wrote:
>All,
>I have been struggling with Manor's graph code and came to a conclusion
>about a statement, which I'd like to get confirmation about...
>
>In BankModelSwarm manor has some code in -buildObjects which is:
>
>for(i=0; i<population; i++) {
>  aName = malloc(10);
>  sprintf(aName, "FE%d",i);
>  [theFNet addNode: [[[[[[[FEntity createBegin: [self getZone]]
>            setCanvas: [theFNet getCanvas]]
>            setModel: self]
>            setFixedIncome: averageIncome]
>            setTotalAgentNum: population]
>            setEntityName: aName]
>            createEnd]];
>  }
>  entityList = [theFNet getNodeList];
>   ...
>
>That one statement is the same as this (Right?):
>
>//forloop
>//name stuff
>aFEntity = [FEntity createBegin: [self getZone]];
>[aFEntity setCanvas: [theFNet getCanvas]];
>[aFEntity setModel: self];
>[aFEntity setFixedIncome: averageIncome];
>[aFEntity setTotalAgentNum: population];
>[aFEntity setEntityName: aName];
>aFEntity = [aFEntity createEnd];
>
>[TheFNet addNode: aFEntity];
>
>}
>
>Right?
>
>What does "entityList = [theFNet getNodeList];" do?
>
>Could the name stuff declared above the "unreadable" statement be
>included in my version of the same code?  Does it have to come before
>it?
>
>Is this an example where the programmer wanted to create "clever" code
>instead of "readable" code?  Why do people do that?
>
>Thanks,
>Brad.
>
>                  ==================================
>   Swarm-Support is for discussion of the technical details of the day
>   to day usage of Swarm.  For list administration needs (esp.
>   [un]subscribing), please send a message to <address@hidden>
>   with "help" in the body of the message.
>                  ==================================
>


                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.
                  ==================================


reply via email to

[Prev in Thread] Current Thread [Next in Thread]