DevPinoy.org
A Filipino Developers Community

>>> First two to make 3 wins! <<<

FluentInterface

So that's what they call it, FluentInterface.  I've noticed this when i first encountered query construction in NHibernate in constructing a query using a criteria:

IList cats = sess.CreateCriteria(typeof(Cat))
    .CreateAlias("Kittens", "kt")
    .CreateAlias("Mate", "mt")
    .Add( Expression.EqProperty("kt.Name", "mt.Name") )
    .List();

The said constructs are also noticeable among mock testing frameworks.


Posted 01-09-2007 9:46 AM by jokiz
Filed under:

Comments

bonskijr wrote re: FluentInterface
on 01-08-2007 9:20 PM

Seen that one before with jQuery(now it's all over Ayende's tools (eg.NH Query Generator and rhino-mocks), before there was a term for that was called chainable methods.

example jQuery(jscript library)

$("p.surprise").addClass("ohmy").show("slow");

jokiz wrote re: FluentInterface
on 01-09-2007 1:59 AM

chainable method, eh. ei, bonski, since you are my first commenter for this year, i owe you one, just inform me if you'll be returning to the phils, you got some laguna goodies from me :p

bonskijr wrote re: FluentInterface
on 01-09-2007 8:22 AM

I don't back down especially with freebies heheh, hopefully this November I'll be there(hopefully inde pa expired yang freebie Stick out tongue)...

cruizer wrote re: FluentInterface
on 01-10-2007 1:16 AM

he he it's in jop's code too!

velocity wrote re: FluentInterface
on 01-10-2007 4:26 AM

Wouldn't this go against the "Law of Demeter"?

http://jayflowers.com/WordPress/?p=78

While I admit that looking at the code it is "seductive", would it not lead to what they call a train wreck --- strong coupling between objects?

Creating a "fluent interface" in this manner does seem more conversational and thus makes code more readable. However,as I understand it from Fowler, fluency has more to do with code that reads like it was a business document describing its domain -- his thinking on domain specific language.

Propecia. wrote Propecia.
on 07-15-2008 8:48 AM

Propecia.


Copyright DevPinoy 2005-2008