The fluent interface
The fluent interface is the API pattern that allows us to chain method calls in a readable and intuitive manner. This term became widely known in 2005, but some people still think of it as just method chaining. However, the main idea is to make the code look like a domain-specific language (DSL). Let’s rework our previous example by introducing a fluent interface technique.
First, let’s define a class to encapsulate the pipeline steps for processing a manuscript:
public class ManuscriptProcessor { private Manuscript _manuscript; public ManuscriptProcessor(Manuscript manuscript) { _manuscript = manuscript; } public ManuscriptProcessor Query(Func<Manuscript, Manuscript> queryFunc) { ...