"with" Coders are Monsters



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


.



Relevant Pages

  • Re: "with" Coders are Monsters
    ... "Johnnie Norsworthy" wrote in message ... 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. ... Maybe a compiler warning that cannot be disabled is warranted: ...
    (borland.public.delphi.non-technical)
  • Re: Result might be undefined?
    ... I thought this bug first appeared in Delphi 7 Update 1? ... So the compiler warning is in fact correct:) ...
    (borland.public.delphi.non-technical)