Questions tagged [fluent-interface]

Refers to a practice of coding object-oriented APIs with the aim of improving readability of the interface, normally implemented using method chaining.

Filter by
Sorted by
Tagged with
11
votes
3answers
3k views

Initializing immutable objects with a nested builder

I need to initialize several parameters of an object but I also wanted to make it immutable. At the same time I don't want the constructor to take all several parameters because some of them are ...
7
votes
1answer
145 views

HTML-rendering framework for emails

Sometimes I need to auto-generate html-emails. To make this task a little bit easier I created a simple framework that takes care of rendering HTML. Because I'm mainly interested in generating HTML ...
7
votes
3answers
945 views

Fluent Validation of Objects

Inspired by this question by t3chb0t and as an elaboration of my own answer, I have written the following solution. My goal was to reduce complexity both in implementation and use. Eventually - I have ...
9
votes
1answer
2k views

Database abstraction layer for multiple providers

There's been a lot of questions lately about database provider and repository design especially without entity framework or alike. I thought I try myself to create a reusable framework for this kind ...
10
votes
6answers
3k views

Fluent interface and polymorphism for building a scene with shapes

I would like to improve the interfaces of some polymorphic classes going from positional to named parameters and I came up with the fluent interface. The following is the most clean, compact and ...
7
votes
2answers
450 views

Fluent Interface for a XmlQueryBuilder

In this answer I suggested using a fluent interface "builder" to replace all the hard-coded, repetitive and quite error-prone inline XML string concatenations. This code might need a bit of tweaking ...
3
votes
0answers
157 views

Extendable REST-Client - follow-up

My previous RestClient wasn't disposing a lot of resources. I've fixed it (hopefully without introducing new issues) and because a few new patterns emerged I did a ...
4
votes
1answer
100 views

Constraining a property setter fluently

The below code is aimed at providing you the most amount of control and flexibility with control which value gets set to a property. I Introduce to you, the ...
3
votes
2answers
218 views

Pizza maker with Bloch builder

I tried to implement the builder pattern of GoF. After searching for almost every related posts/examples on the Internet, I'm still confused. But I found that there are two kinds of patterns, which ...
3
votes
1answer
103 views

Guided object builder

Sometimes when designing a fluent-api it's important to build an object in a specific way/sequence. I tried to create such a guided builder and came-up with this: ...