<$BlogRSDUrl$>

Friday, August 06, 2004

Another cross against with 

An ADUG member (name suppressed to protect the innocent) unleashed this code on the mailing list today. Add it to the mounting stack of evidence as to why using with is not a good idea.


n := -1; { counter which identifies which group index we are up to }
with TProjectAlias(gAliases.Items[PrjIndex]) do begin
with TNetList(PNetIndex.Items[NetIndex]) do begin
with TAppIndex(ApplIndex.Items[AppIndex]) do begin
for i := 0 to SortedLevels.Count - 1 do begin
with TLevelEntry(SortedLevels.Items[i]) do begin
if GroupAdd = StrPas(inGrpAdd) then begin
n := n + 1; { increment count }
if n = inIndex then begin { check if it is the right one }
tmpDesc := TLevelEntry(SortedLevels.Items[i]).Desc; { copy description }
StrPCopy(outDesc, PadString(tmpDesc, DESC_LENGTH));
break;
end; { if }
end; { if }
end; { with }
end; { for }
end; { with }
end; { with }
end; { with }




Granted, like most starting out Delphi developers I initially embraced the concept (wow, think of all the typing I'm saving with this great feature), but gave away the notion a few years ago due to it being harder to maintain, and the ambiguity issues it can create. I used to make an exception when creating class functions to show modal forms (as shown below), but I've even stopped doing that now.


with TSomeForm.Create(nil) do
try
Result := ShowModal;
finally
Free;
end;


Comments:
Good looking blog you have.
I always refreshing to see creativity.
Wish you the best!
If you would like you might visit my site:
##webdesign## It is all about##yourfuture## having your own website.
Come and visit if you like.
Phil
 
Good looking blog you have.
I always refreshing to see creativity.
Wish you the best!
If you would like you might visit my site:
##webdesign## It is all about##yourfuture## having your own website.
Come and visit if you like.
Phil
 
Sure have alot of info here, I really like your site.
I will probably visit here again. Have a great life.
If you would like you might visit my site:
##webdesign## It is all about##yourfuture## having your own website.
Come and visit if you like.
Phil
 
Wonderful blog, I really like it!
keep up the good work in what ever you go for.
If you or anyonre you know is interested in starting a website, you could go to my site/blog and check out what I have to offer: ##freedom##
What's in your ##family## immediate future?
If you have any interest.
Phil
 
Hey, you have a great blog here! I'm definitely going to bookmark you!

I have a ##yourownboss## site/blog. It pretty much covers ##website## related stuff.
Come and check it out if you get time :-)
Phil
 
Finding great things on this internet. Your site is one.
Don't ever lose sight of what you believe in.
If you would like you might visit my site:
##webdesign## It is all about##yourfuture## having your own website.
Come and visit if you like.
Phil
 
Well you never know what interesting things are out
there to see, until you see a blog like yours.
Looks good! Keep it up!
Come see my site/blog if you like
##independence## it may be of##Future## interest to you.
If you find the time.
Phil
 
Some great info here!
If you have a few minutes pay a visit to my
videogames site.
 
Wonderful blog, I really like it!
keep up the good work in what ever you go for.
If you or anyonre you know is interested in starting a website, you could go to my site/blog and check out what I have to offer: ##freedom##
What's in your ##family## immediate future?
If you have any interest.
Phil
 
Post a Comment

This page is powered by Blogger. Isn't yours?