Practices yegor256.com

Fluent interfaces are bad for maintainability  ↦

Yegor Bugayenko:

Fluent interface, first coined as a term by Martin Fowler, is a very convenient way of communicating with objects in OOP. It makes their facades easier to use and understand. However, it ruins their internal design, making them more difficult to maintain. A few words were said about that by Marco Pivetta in his blog post Fluent Interfaces are Evil; now I will add my few cents.

Yegor uses his own HTTP library as an example where the interface designed is fluent (which looks nice and readable to use) and shows how that design goal made the internal code a mess. My gut tells me it’s worth the trade-off to provide a better user experience, but Yegor’s real-life experience punches me right in the gut:

Fluent interfaces are perfect for their users… However, the damage they cause to object design is the price, which is too high.

He suggests decorators and smart objects as an alternative. Lots to ponder here, and the conversation going on in the comments is lively as well. 👌


Discussion

Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00