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 140091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:33:09+00:00 2026-05-11T07:33:09+00:00

I was recently watching a webcast about how to create a fluent DSL and

  • 0

I was recently watching a webcast about how to create a fluent DSL and I have to admit, I don’t understand the reasons why one would use such an approach (at least for the given example).

The webcast presented an image resizing class, that allows you to specify an input-image, resize it and save it to an output-file using the following syntax (using C#):

Sizer sizer = new Sizer(); sizer.FromImage(inputImage)      .ToLocation(outputImage)      .ReduceByPercent(50)      .OutputImageFormat(ImageFormat.Jpeg)      .Save(); 

I don’t understand how this is better than a ‘conventional’ method that takes some parameters:

sizer.ResizeImage(inputImage, outputImage, 0.5, ImageFormat.Jpeg); 

From a usability point of view, this seems a lot easier to use, since it clearly tells you what the method expects as input. In contrast, with the fluent interface, nothing stops you from omitting/forgetting a parameter/method-call, for example:

sizer.ToLocation(outputImage).Save(); 

So on to my questions:

1 – Is there some way to improve the usability of a fluent interface (i.e. tell the user what he is expected to do)?

2 – Is this fluent interface approach just a replacement for the non existing named method parameters in C#? Would named parameters make fluent interfaces obsolete, e.g. something similar objective-C offers:

sizer.Resize(from:input, to:output, resizeBy:0.5, ..) 

3 – Are fluent interfaces over-used simply because they are currently popular?

4 – Or was it just a bad example that was chosen for the webcast? In that case, tell me what the advantages of such an approach are, where does it make sense to use it.

BTW: I know about jquery, and see how easy it makes things, so I’m not looking for comments about that or other existing examples.

I’m more looking for some (general) comments to help me understand (for example) when to implement a fluent interface (instead of a classical class-library), and what to watch out for when implementing one.

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-11T07:33:09+00:00Added an answer on May 11, 2026 at 7:33 am

    2 – Is this fluent interface approach just a replacement for the non existing named method parameters in C#? Would named parameters make fluent interfaces obsolete, e.g. something similar objective-C offers:

    Well yes and no. The fluent interface gives you a larger amount of flexibility. Something that could not be achieved with named params is:

    sizer.FromImage(i)  .ReduceByPercent(x)  .Pixalize()  .ReduceByPercent(x)  .OutputImageFormat(ImageFormat.Jpeg)  .ToLocation(o)  .Save(); 

    The FromImage, ToLocation and OutputImageFormat in the fluid interface, smell a bit to me. Instead I would have done something along these lines, which I think is much clearer.

     new Sizer('bob.jpeg')   .ReduceByPercent(x)  .Pixalize()  .ReduceByPercent(x)  .Save('file.jpeg',ImageFormat.Jpeg); 

    Fluent interfaces have the same problems many programming techniques have, they can be misused, overused or underused. I think that when this technique is used effectively it can create a richer and more concise programming model. Even StringBuilder supports it.

    var sb = new StringBuilder();  sb.AppendLine('Hello')  .AppendLine('World');  
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was recently watching a webcast on Clojure. In it the presenter made a
Recently I have been investigating the possibilities of caching in ASP.NET. I rolled my
Recently a friend and I were talking about securing stored procedure code in a
I watched this webcast recently, and I got the sense that a lot of
I recently watching this video on Google Chrome with great interest. It explains that
I was recently watching a google lecture on mysql and learnt that MySQL wont
I have been watching the growing visibility of functional programming languages and features for
I have heard several podcasters (most recently the guys on DotNetRocks ) say that
Recently I've started hearing about POJOs (Plain Old Java Objects). I googled it, but
I've recently created a dropbox system using inotify, watching for files created in a

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.