concept fluent interface in category design

appears as: fluent interfaces, fluent interface
Object Design Style Guide

This is an excerpt from Manning's book Object Design Style Guide.

4.13. Don’t implement fluent interfaces on mutable objects

An object has a fluent interface when its modifier methods return this. If an object has a fluent interface, you can call method after method on it, without repeating the variable name of the object.

Listing 4.37. QueryBuilder offers a fluent interface
queryBuilder = QueryBuilder.create()
    .select(/* ... */)
    .from(/* ... */)
    .where(/* ... */)
    .orderBy(/* ... */);

However, a fluent interface can be very confusing regarding which object a method gets called on. If QueryBuilder is immutable, then it doesn’t really matter. But who knows if it’s mutable? If you look at the method signatures of QueryBuilder in the following listing, there’s no way to find that out.