Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:


+972 52-548-6969

, @ Q c

Posts: 6,125 | Comments: 45,486

filter by tags archive

Fluent Interfaces & Method Chaining

time to read 1 min | 191 words

Hammett calls the term "Fluent Interface" unnecessary:

And about Fluent interfaces, what about OOP? What about method chaining? Does it need, for god’s sake, a new name?

This is method chaining:

string user = new StringBuilder()
	.Append("Name: ")
	.Append("Email: ")

And this is a fluent interface:

return new Finder<Order>(
		Where.Order.User == CurrentUser &&
			Where.Order.TotalCost > Money.Dollars(150) ||
			Where.Order.OrderLines.Count > 15

Anders posts about DSL building contains examples that are tied more closely to the domain.

Method chaining is something that you would certainly use in the a fluent interface, but that is like saying that you need to use interfaces when you build a plugin framework. The fact that you are using something doesn't mean that what you do is only that something.

Fluent interfaces are different than merely method chaining because they allow you to express your intent in the domain terms and allows you to get more readable code. Method chaining, operator overloading, nasty generics tricks are all part of that, certainly, but the end result is much more than just a simple method chain.

And yes, I think that it certainly deserves its own name.


Joe Ocampo

Having recently worked on creating a so called fluent interface I can definately say it is alot more than method chaining.

Method chaining is to fluent interfaces :: hammering nails is to building a wall

I think it deserves it's own name as well.

I vote for “Comprehensible Interface”


I think Hammett was having a bad day ... a very unusual outburst :)

I can see where he might come from, Martin does have the odd attempt at redefining things to suit him better, and some people take his stuff as gospel a little too easily. But overall, I'm pretty sure Martin is a force for good rather than evil :)


Jealousy, perhaps.


I don't know, I've studied the idea, thought about fluency for a system or two -- where there is the possibility for a bit of evolution beyond chaining and for greater DSL-ness -- and it still strikes me as more "cute-sy" than vital... From everyone I've shown it to, the response has been more 'aha' than 'Aha!!' Hard to get traction, unless someone else gets smitten with the idea.

I'd love to see someone make The Case for fluent interfaces, to show the quintessential example that makes this design pattern worthy of entry into the canon (not the kludgey SQL/XQuery/LINQ exemplar that's everywhere, which just makes the subject more confusing). Because make no mistake, this a heavyweight design pattern.

I'm willing to be converted, though.

Last 2c: 'Fluent' seems a decent enough name. Maybe SentenceObjects - or Sent-a-Clause :)


If you guys wanna see Fluent Interface in Action, check this out


Andrew Hallock

How is the StringBuilder example not a fluent interface for its own "stringy" domain?

So expressive OOP + chaining methods == fluent interface? Or is it simply that method chaining is a construct you can employ in OOP?

Steve Freeman

I worked on jMock, the poster child for fluent interfaces before Martin got involved. We started with method chaining because I missed Smalltalk cascades but after a few generations it turned into something very different.

One of the core differences is that a Fluent Interface will guide you as to what to do next, whereas method chaining is just about less typing (a Good in itself). Programming a good Fluent Interface with a good IDE largely consists of hitting Ctrl-Space or Alt-Tab or whatever.

For all the gory details, try our OOPLSA paper at http://www.mockobjects.com/files/evolvinganedsl.ooplsa2006.pdf

Ayende Rahien

Not enough domain, and very little that actually goes beyond method chaining.

Troy DeMonbreun

I wrote a article showing some "quick example" code illustrating how to build a Fluent Interface in C#:




Comment preview

Comments have been closed on this topic.


  1. The design of RavenDB 4.0: Physically segregating collections - one day from now
  2. RavenDB 3.5 Whirlwind tour: I need to be free to explore my data - about one day from now
  3. RavenDB 3.5 whirl wind tour: I'll have the 3+1 goodies to go, please - 5 days from now
  4. The design of RavenDB 4.0: Voron has a one track mind - 6 days from now
  5. RavenDB 3.5 whirl wind tour: Digging deep into the internals - 7 days from now

And 12 more posts are pending...

There are posts all the way to May 30, 2016


  1. The design of RavenDB 4.0 (14):
    03 May 2016 - Making Lucene reliable
  2. RavenDB 3.5 whirl wind tour (14):
    04 May 2016 - I’ll find who is taking my I/O bandwidth and they SHALL pay
  3. Tasks for the new comer (2):
    15 Apr 2016 - Quartz.NET with RavenDB
  4. Code through the looking glass (5):
    18 Mar 2016 - And a linear search to rule them
  5. Find the bug (8):
    29 Feb 2016 - When you can't rely on your own identity
View all series


Main feed Feed Stats
Comments feed   Comments Feed Stats