I think better names for "i" could include
var iDontKnowWhatToCallThisIntegerVariable, iReallyShouldThinkOfAMoreDescriptiveName, iRelyWshICouldSpelCorectly : integer
Alister Christie Computers for People Ph: 04 471 1849 Fax: 04 471 1266 http://www.salespartner.co.nz PO Box 13085 Johnsonville Wellington
James Sugrue wrote:
Yip agree with that. But I think you have taken my code out of context.
All I was saying is that i j etc are ok when only used once in a loop or for looping constraints. I.E when its obvious what is going on and a long name really isn't needed.
I think a name like iLoopCounter is superfluous in the context of the
code I posted as it is obvious what i is used for.
On Fri, 2004-09-24 at 14:52, Traci Sumpter wrote:
When it is in the middle of a long procedure it helps if you dont have to keep looking back in the code to see what you are meant to be doing.
//commenting can help lots too.....
As I said in my original I have a lot of work going over other peoples code and often months after creation. So many times i get code like
i := Query1.Fields[j].Integer; Table1.Fields[i].asString := s;
in the middle of many
While i < j do loops and s is defined somewhere in the middle of another loop.
In these situations it is impossible to understand what is trying to be achieved and how to fix the bug that is created.
Is this a better example when more descriptive varible names become essential????
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of James Sugrue Sent: Friday, 24 September 2004 2:36 p.m. To: NZ Borland Developers Group - Delphi List Subject: RE: [DUG] DiamondBack Sneak Peek (Delphi 9)
Sorry can't agree. How is iCountFiles better than i. i is just a place holder in a loop. Anyone with more than an elementary level of programming will understand what is going on at a glance.
I will concede that s could be more descriptive and possibly wasn't a good example.
On Fri, 2004-09-24 at 14:01, Traci Sumpter wrote:
except 5 months down the track when it would be a lot easier to unserstand
procedure DoSomethingorOther; var sFileList : string; iCountFiles : Integer; begin for iCountFiles := 0 to Pred(someList.Count) do begin sFileList := someList.Items[iCountFiles]; doSomething(sFileList); end; end;
This means I can look at this short bit of code and can make assumptions that I am going through a list of Files and doing something with it.
what does the other version of code allow you to make assumtions about..
Assume Ass out of you and me... I know
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of James Sugrue Sent: Friday, 24 September 2004 1:25 p.m. To: NZ Borland Developers Group - Delphi List Subject: RE: [DUG] DiamondBack Sneak Peek (Delphi 9)
I would have though i and j would be fine for loops and s for strings. x and y for anything to do with co-ords as well.
I think the following is fine:
procedure DoSomethingorOther; var s : string; i : Integer; begin for i := 0 to Pred(someList.Count) do begin s := someList.Items[i]; doSomething(s); end; end;
On Fri, 2004-09-24 at 12:41, [EMAIL PROTECTED] wrote:
Good practice (not always =) VCL source
True, the VCL also uses _with_.
Each to there own - but globally condemned is a bit rich
for multitudes of good reasons.
name some then
What did you search on in google. _______________________________________________ Delphi mailing list [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
_______________________________________________ Delphi mailing list [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
_______________________________________________ Delphi mailing list [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
_______________________________________________ Delphi mailing list [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
_______________________________________________ Delphi mailing list [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
_______________________________________________ Delphi mailing list [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
_______________________________________________ Delphi mailing list [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
