Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7491525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:04:14+00:00 2026-05-29T16:04:14+00:00

Situation I’d like to make an RPC interface easier to use. This is a

  • 0

Situation

I’d like to make an RPC interface easier to use. This is a custom interface so there is no readily available wrapper.

I have to write several 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 has to 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 a wrapper method for each function:

procedure TRPCInterface.DoSomething(AArg1: Integer; AArg2: string; AArg3: Boolean);

The caller can simply call it:

TRPCInterface.DoSomething(0, ...);

Pro and contra

Method 1 – Class for each function

Contra

  • More code required.
  • An object must be created which takes up memory.

Pro

  • Reading the code is easier, you don’t have to look at the declaration to see what the arguments are.

Method 2 – Wrapper method

Contra

  • You can’t tell which arguments are used by just looking at the code.

Pro

  • Much less code to write.
  • The wrapper is thinner (no object has to be created).

Which method should I use?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T16:04:15+00:00Added an answer on May 29, 2026 at 4:04 pm

    There is an intermediate solution that is calling the wrapper methods passing an object argument.

    TDoSomethingArgs = class
    public
      property Arg1: Integer;
      property Arg2: string;
      property Arg3: Boolean;
    end;
    
    procedure TRPCInterface.DoSomething(Args: TDoSomethingArgs);
    

    one advantage of this method is that you still use methods, but still it’s more readable.
    One advantage of using classes (you can also use records) in arguments is that you can later change the arguments (add more, change behavior) and if you choose it well, it does not break backward compatibility – in summary you can change method signature without breaking code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

[Situation] I have a custom item control which I add to a stack panel
Situation: I have a simple XML document that contains image information. I need to
Situation: text: a string R: a regex that matches part of the string. This
Situation: I have some persons with certain skills and they can/might belong to more
Situation is you have to develop an application against an Active Directory Tree. Want
Situation Well, as you can see below, I have a main App, creating a
Situation: I am trying to write a efficient query using "LIKE" statement to look
Situation: I have an UIView with an UIWebView in it. When the viewDidLoad the
Situation: Automatically generated memebers, such as MenuStrip items, have their (automatically generated) names based
Situation: I have an Xcode project based on the Navigation-Based-Application template. So that means

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.