Wednesday, November 23, 2005

Var injection and code completion

One of the great new things of Delphi 2006 is Var injection. It allows you to declare a variable in the middle of your code while the IDE takes care of placing it in the var section of your procedure. (At Nick's delphi blog post you can see how it actually works.)

No doubt, this kind of tricks boost your productivity!

Thinking it over, one of the things that, sometimes annoys me in Delphi coding is the fact that the procedure head in the initialization section of the unit must be the same as the procedure decleration itself. In fact this is no problem, but is has to be maintained during changes in, for example the parameters of the procedure.
For new procedures Code completion takes care of this when you create either the initialize or the procedure itself.

For example typing this in the initialization section of your unit:

procedure MyProcedure;

Clicking Control+SHIFT+C makes the procedure itself:

procedure TMyForm.MyProcedure;
begin

end;

This is great!, however adding an additional parameter in code (after rethinking the procedure) forces you to change the other manually. And that is in big units a lot of code cruising.

Would it be a good idea to use code completion also on existing procedures, so that for example editing the above procedure like this:

procedure MyProcedure(IForgotAParameter : Boolean);
begin
//Do some stuff
end;

....clicking Control+SHIFT+C updates the initialization section and vica versa.

Maybe the together support in Delphi2006 makes this easier?
Don't know, have to wait a little longer.........by the way 29 november 2005, Dutch Delphi 2006 launch in Hoofdorp. For more information click here.

1 comment:

Anonymous said...

Nice blog, interesting stuff :)
The Ctrl + Shift + C has been around for a few years, and about cruising trough the code to change procedure parameters manually, the Ctrl + Shift + UpArrow & DownArrow keys are very very handy :)

Greetings, Delphiwizard

Use an image as your UIBarButtonItem

Using an image as your UIBarButtonItem in your navigationcontroller bar can only be achieved by using a common UIButton as the BarButtonItem...