Too many variables can indicate that a routine is doing too many things.
Using many variables in a routine can be an indicator that the routine is doing too many things. A routine should be a single logical task, not a number of disconnected tasks.
Using a large number of redundant variables in a short span of code can also adversely affect readability.
Consider breaking the routine up into multiple routines with different responsibilities:
procedure TMyObject.DoThing; var MyFoo: TFoo; MyBar: TBar; begin MyFoo := TFoo.Create; FMyFoo := MyFoo; MyBar := TBar.Create; FMyBar := MyBar; end;
procedure TMyObject.DoFooThing; var MyFoo: TFoo; begin MyFoo := TFoo.Create; FMyFoo := MyFoo; end; procedure TMyObject.DoBarThing; var MyFoo: TFoo; begin MyBar := TBar.Create; FMyBar := MyBar; end;
Another option is to inline unnecessarily verbose variables:
procedure TMyObject.DoThing; var MyFoo: TFoo; MyBar: TBar; begin MyFoo := TFoo.Create; FMyFoo := MyFoo; MyBar := TBar.Create; FMyBar := MyBar; end;
procedure TMyObject.DoThing; begin FMyFoo := TFoo.Create; FMyBar := TBar.Create; end;