views:

251

answers:

3

I am wondering where and when fluent interfaces are a good idea, so I am looking for examples. So far I have found only 3 useful cases, e.g. Ruby's collections, like

unique_words = File.read("words.txt").downcase.split.sort.uniq.length

and Fest (Java) for unit testing:

assertThat(yoda).isInstanceOf(Jedi.class)
    .isEqualTo(foundJedi)
    .isNotEqualTo(foundSith);

and JMock. Do you know of any other good examples that use a fluent interface?

+3  A: 

jQuery. :)

cletus
My Dog! jQuery IS always the answer!
Kawa
+1  A: 

StringBuilder: http://msdn.microsoft.com/en-us/library/system.text.stringbuilder(VS.71).aspx Or

TcKs
A: 

RSpec. Example from the home page:

# bowling_spec.rb
require 'bowling'

describe Bowling do
  before(:each) do
    @bowling = Bowling.new
  end

  it "should score 0 for gutter game" do
    20.times { @bowling.hit(0) }
    @bowling.score.should == 0
  end
end
AShelly