Situation
I would like to make the RPC interface easier to use. This is a customizable interface, so there is no wrapper available.
I need to write some wrappers around functions, which often have many arguments.
Possible solutions
Solution 1 - Using a class for each function:
TDoSomethingFunction = class
public
property Arg1: Integer;
property Arg2: string;
property Arg3: Boolean;
procedure Run;
end;
The caller must create an object to call the function:
var
DoSomething: TDoSomethingFunction;
begin
DoSomething := TDoSomethingFunction.Create;
try
DoSomething.Arg1 := 0;
...
DoSomething.Run;
finally
free;
end;
Method 2 - using the wrapper method for each function:
procedure TRPCInterface.DoSomething(AArg1: Integer; AArg2: string; AArg3: Boolean);
The caller can simply call him:
TRPCInterface.DoSomething(0, ...);
Pro and contra
Method 1 - a class for each function
Contra
- More code required.
- An object must be created that takes up memory.
Pro
- Reading the code is simpler, you do not need to look for an ad to find out what arguments are.
Method 2 - Wrap Method
Contra
Pro
?