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

  • Home
  • SEARCH
  • 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 3999042

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:36:18+00:00 2026-05-20T07:36:18+00:00

What are the pros and cons in using fluent interfaces in Delphi? Fluent interfaces

  • 0

What are the pros and cons in using fluent interfaces in Delphi?

Fluent interfaces are supposed to increase the readability, but I’m a bit skeptical to have one long LOC that contains a lot of chained methods.

Are there any compiler issues?
Are there any debugging issues?
Are there any runtime/error handling issues?

Fluent interfaces are used in e.g. TStringBuilder, THTMLWriter and TGpFluentXMLBuilder.


Updated:
David Heffernan asked which issues I was concerned about. I’ve been given this some thought, and the overall issue is the difference between “explicitly specifying how it’s done” versus “letting the compiler decide how it’s done”.

AFAICS, there is no documentation on how chained methods actually is handled by the compiler, nor any specification on how the compiler should treat chained methods.

In this article we can read about how the compiler adds two additional var-parameters to methods declared as functions, and that the standard calling convention puts three params in the register and the next ones on the stack. A “fluent function method” with 2 params will therefor use the stack, whereas an “ordinary procedure method” with 2 params only uses the register.

We also know that the compiler does some magic to optimize the binary (e.g. string as function result, evaluation order, ref to local proc), but sometimes with surprising side effects for the programmer.

So the fact that the memory/stack/register-management is more complex and the fact that compiler could do some magic with unintentional side effects, is pretty smelly to me. Hence the question.

After I’ve read the answers (very good ones), my concern is strongly reduced but my preference is still the same 🙂

  • 0 0 Answers
  • 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-20T07:36:19+00:00Added an answer on May 20, 2026 at 7:36 am

    Compiler issues:

    If you’re using interfaces (rather than objects), each call in the chain will result in a reference count overhead, even if the exact same interface is returned all the time, the compiler has no way of knowing it. You’ll thus generate a larger code, with a more complex stack.

    Debugging issues:

    The call chain being seen as a single instruction, you can’t step or breakpoint on the intermediate steps. You also can’t evaluate state at intermediate steps.
    The only way to debug intermediate steps is to trace in the asm view.
    The call stack in the debugger will also not be clear, if the same methods happens multiple times in the fluent chain.

    Runtime issues:

    When using interfaces for the chain (rather than objects), you have to pay for the reference counting overhead, as well as a more complex exception frame.
    You can’t have try..finally constructs in a chain, so no guarantee of closing what was opened in a fluent chain f.i.

    Debug/Error logging issues:

    Exceptions and their stack trace will see the chain as a single instruction, so if you crashed in .DoSomething, and the call chain has several .DoSomething calls, you won’t know which caused the issue.

    Code Formatting issues:

    AFAICT none of the existing code formatters will properly layout a fluent call chain, so it’s only manual formatting that can keep a fluent call chain readable. If an automated formatter is run, it’ll typically turn a chain into a readability mess.

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

Sidebar

Related Questions

I would like to have a reference for the pros and cons of using
What are the pros/cons of using black-box reuse over white-box reuse?
What's pros and cons of using Enterprise Library Unity vs other IoC containers (Windsor,
What are the pros and cons of using table aliases in SQL? I personally
What are the pros and cons of using a hosting provider for a Subversion
What are the pros and cons of using Criteria or HQL ? The Criteria
What are the pros and cons of using nested public C++ classes and enumerations?
What are the pros and cons of using System.Security.Cryptography.RNGCryptoServiceProvider vs System.Random . I know
I wish to know all the pros and cons about using these two methods.
I would like to know what the pros and cons are for using an

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.