vendredi 20 mai 2016

Naming Convention - Argument used to hold the results of a method

The following code is passing an object of type TList<integer> to a method Split. Within the method a number gets split into single digits which are then added to a list passed into the method as the second parameter.

Question:

Is there any naming convention to improve readability of the method or parameter itself to that effect that it is clear the second argument is used as the result of the method. I tried using named parameters for this purpose, but it seems that this is not supported in Delphi: Split(arabicNumber, toList:= numbers);.

Code:

var
  numbers: TList<integer>;
  arabicNumber: integer;
begin
  try
    numbers := TList<integer>.Create();
    Split(arabicNumber, numbers); // how can I make it clear that numbers is getting filled within the method
    // do something with numbers
    result := ...;
  finally
    numbers.Free();
  end;
end;

procedure TRomanNumeral.Split(const number: integer; list: TList<integer>);
begin
  // iterate over number and add each single digit to list
  list.Add(digit);
end;

Aucun commentaire:

Enregistrer un commentaire