"with" Coders are Monsters
- From: "Johnnie Norsworthy" <jln206@xxxxxxxxxxx>
- Date: Wed, 11 Jul 2007 14:07:13 -0700
Why oh why, must Delphi have a with statement?!
I have been working on some "with" programmer's code and I just don't see
the attraction. I know retyping the same thing many times is a pain, but
with code insight it isn't half bad, and maintenance programmers could
actually read the code.
All I do when there is going to be a large block, say using a table in a
datamodule in a separate unit, is create a local variable with a short name
and assign it at the beginning of the procedure:
var
Table: TWhateverTable;
begin
Table := DataModuleName.TableInThatFarAwayDataModule;
Table.FieldByName('field').AsString := 'Yippee';
// more of the same
So very much more legible and comprehendable than
with DataModuleName.TableInThatFarAwayDataModule do
begin
// insert far too huge block of crap here so indenting is useless
end;
Maybe a compiler warning that cannot be disabled is warranted:
"Note: You are using "with". Maintenance programmers "with" torches and
clubs will hunt you down
Venting completed. (1% error - acceptable compilation)
-Johnnie
.
- Follow-Ups:
- Re: "with" Coders are Monsters
- From: Olivier Pons
- Re: "with" Coders are Monsters
- From: Gerrit Beuze
- Re: "with" Coders are Monsters
- From: Dean Hill
- Re: "with" Coders are Monsters
- From: Andrew Fiddian-Green
- Re: "with" Coders are Monsters
- From: Hallvard Vassbotn
- Re: "with" Coders are Monsters
- From: Donald Shimoda
- Re: "with" Coders are Monsters
- From: Johnnie Norsworthy
- Re: "with" Coders are Monsters
- From: Michael Little
- Re: "with" Coders are Monsters
- From: Charles McAllister
- "uses" Coders are Monsters too...
- From: Andrew Fiddian-Green
- Re: "with" Coders are Monsters
- From: Bill Mullen
- Re: "with" Coders are Monsters
- From: Uwe Raabe
- Re: "with" Coders are Monsters
- From: David Berneda
- Re: "with" Coders are Monsters
- From: Farshad
- Re: "with" Coders are Monsters
- From: Eric Grange
- Re: "with" Coders are Monsters
- From: Jan Derk
- Re: "with" Coders are Monsters
- From: somebody
- Re: "with" Coders are Monsters
- From: Phillip Woon
- Re: "with" Coders are Monsters
- From: Diego
- Re: "with" Coders are Monsters
- From: Mark Andrews (The Other One)
- Re: "with" Coders are Monsters
- From: Nick Hodges (CodeGear)
- Re: "with" Coders are Monsters
- From: Sarah
- Re: "with" Coders are Monsters
- From: Rudy Velthuis [TeamB]
- Re: "with" Coders are Monsters
- From: John Herbster
- Re: "with" Coders are Monsters
- From: Brian Parliament
- Re: "with" Coders are Monsters
- From: GrandmasterB
- Re: "with" Coders are Monsters
- Prev by Date: Re: A company to learn from?
- Next by Date: Re: "with" Coders are Monsters
- Previous by thread: Is .NET right for small utilities that need to run all the time?
- Next by thread: Re: "with" Coders are Monsters
- Index(es):
Relevant Pages
|