Facilitating the spread of knowledge and innovation in professional software development



Choose your language

InfoQ Homepage Presentations Why I've Come to Prefer Fluent APIs Over Other Kinds of DSLs

Why I've Come to Prefer Fluent APIs Over Other Kinds of DSLs



John Slaby discusses the reasons why he prefers fluent APIs and examine, through examples, the many different ways that Fluent APIs can be used to help produce better solutions than external DSLs.


John Slaby is an Engineering Fellow at Raytheon with over 25 years experience in software and systems engineering. At Raytheon, he has been a Software Architect on numerous programs and was the Principal Investigator for research projects on model-driven software development and domain-specific modeling languages. He is currently the engineering lead on an applied research project.

About the conference

Code Generation conference is the leading event on the practical applications of Model-Driven Software Development (MDSD). It offers a high quality learning experience through discussions, debates, a diverse range of practical tutorials and workshops. Now in its 7th year, it is known for providing a high-value learning experience and attracts industry-recognised experts to share their experiences.

Recorded at:

Aug 30, 2014

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

  • With Operator

    by Ror Pop,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    The "with operator" provides an alternative to fluent-style APIs..

    In xTend, you can write:
    this.gameState = GameStateFactory.DefaultGameState( => [

    The with operator accepts a lambda expression (equivalent to Action<GameState>), and returns the object it was applied on.

    The object instance is an implied context in the lambda body, and you can invoke any methods on it. You can also use the "it" keyword to refer to it explicitly.

    This way, you don't need to modify all methods to return the object instance.

    Another advantage is that you can include arbitrary code in the lambda body.

    See here:

    I wish C# had that feature as well.

  • Demo App

    by Ricardo Sotolongo,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Is the Baseball Scoring App repository available online or is just code snippets?

  • Why not use lemonade instead of gas in the car then?

    by Sumant Tambe,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Fluent interfaces is a "DSL" for programmers to the extent that programming is a domain. I fail to understand the thesis of this presentation. A DSL is for domain experts. If you throw a DSL at a person who is not a domain expert, the reaction is expected to be what the speaker says: "What the heck is this thing?" That leaves only two possibilities: First, the DSL wan't good enough and did not capture the "domain" well enough. It was probably so bad that a "domain expert" did not see his domain ideas expressed in the language at all. Alternatively, the new team of people were really programmers and not domain experts. So they did not get squat out of the DSL. If a team can replace a well-designed DSL with just a fluent API, they would as well put lamonade in their cars instead of gas.

    However, I like the speaker's comment: "... have become pragamtic enough to take small victories..."

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p


Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.