Fluent Interfaces

company.hires(“law firm”, “criminal law”) was Alef’s example of a fluent interface. If you found it interesting here’s the link to Martin Fowler’s website where he talks about it.

One thought on “Fluent Interfaces

  1. Fluent interfaces are very interesting. They’ve been making their way into PHP as well. The best example I’ve seen so far where a fluent interface would make sense in PHP was in a Database class, where you would get:


    Now this is a beautiful way of writing queries, and teh abstraction takes care that the correct query syntax is used for the database system that you’re using.

    Another example, very interesting, from one of the big shots in PHP Mike Naberezny, is the creation of an order:

    ->with(6, ‘TAL’)
    ->with(5, ‘HPK’)->skippable()
    ->with(3, ‘LGV’)

    So yes, fluent interfaces are very interesting.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s