swarm-support
[Top][All Lists]
Advanced

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

Clever code vs. readable code...


From: bleydorf
Subject: Clever code vs. readable code...
Date: Tue, 11 Nov 1997 13:03:20 -0500

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.
                  ==================================


reply via email to

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