Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
1answer
89 views

Chaining ConstrainableSet<T> [on hold]

Based on feedback on my previous question, I made many small adjustments to the code, added more APIs and tried to follow through with delivering on the excellent advice I have received in regards to ...
4
votes
1answer
93 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 ...
0
votes
1answer
59 views

Recursive fluent builder

Problem statement I have entities whose relations form a graph. As an example, let's imagine Users and Groups. Each user has a <...
3
votes
1answer
84 views

Simple fluent library to validate text content

Before I can perform a more or less complex mappings, treatments in business objects and saving results in databases, I often need to validate contents from flat text files or excel files All the ...
0
votes
1answer
76 views

Fluent interface for Logger

I was trying to wrap a Logback logger in order to provide some handy methods and already defined default keys of the logged json output and I came up with something like this. Do you spot any ...
2
votes
1answer
70 views

Switch-like functionality for non-switchable types in Java

Intro This class emulates a switch statement, in order to include non-switchable types (POJOs) have the same switch statement executable for different values be ...
1
vote
1answer
77 views

Wrapper for a sales API, with a fluent interface

I've created a simple API wrapper that I intend a few developers to utilize. I decided to follow an Fluent Interface methodology, similar to this. ...
3
votes
0answers
130 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
80 views

Java builder for user contact information, with optionals

I have this simple builder here: ...
2
votes
2answers
174 views

API with revealing module pattern in Javascript

I'm working on a project where I want to create a API that can be used to do some mathmatical calculations. Here are the important aspects: I used the revealing module pattern I added method ...
7
votes
1answer
533 views

Pathfinding library in C++ with fluent API

Introduction I have this C++ pathfinding library. My primary requirement is that a client programmer may couple his/her own graph representation and the library will work with that representation. ...
3
votes
0answers
109 views

Instantiating an animal using fluent classes with inheritance

I've spent a couple of weeks implementing a simple text editor. The entire program uses only immutable objects and a functional, fluid programming style. After reading about ways to implement Fluent ...
2
votes
0answers
566 views

JObject Pattern Matching: Merging partial WEB API JSON payload

This library [GitHub] helps merging partial WEB API JSON payload with existing prepopulated DTO objects. Let's say that JSON is represented by JObject from JSON.NET package. Naïve implementation ...
5
votes
3answers
499 views

Pizza builder with fluent interface

I make my original program more interesting and try to make the builder API more easier to read: Now it's a static method of Builder: Pizza.Builder.recipeBuild(...) ,who bake the pizza with your ...
3
votes
2answers
201 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 ...
2
votes
3answers
3k views

Methods to create C# dictionaries, with static keys/values, in fluent notation

I created these little utility methods to build fluent C# dictionaries. The value declarations shall be quick to write and easy to comprehend when somebody views the code. Usage conditions are as ...
0
votes
2answers
57 views

Hibernate MassIndexer using chained invocation for building a batch job

I've a class called MassIndexer.java (on GitHub) and it uses chained invocation for building a batch job. Each method assigns a property of this job and finally the ...
0
votes
1answer
159 views

Fluent interface builder

I'm working on a fluent interface builder that takes: an array of strings, each of which becomes a key to an object that is a function that follows the fluent interface pattern a terminator function ...
9
votes
1answer
1k 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 ...
6
votes
3answers
95 views

Table printing code using a fluent interface

Let's say you want to display something like: One Two Three Four 1 2 3 4 And since you hate the idea of predefining the widths of the columns you ...
7
votes
1answer
141 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 ...
3
votes
0answers
56 views

Easily add Accessibility to your app as an afterthought. Yes, as an afterthought

Accessible apps allow more users to use your app; however, it is usually an afterthought for developers, and it makes your XML layout files messy whether Accessibility was a forethought or ...
2
votes
1answer
95 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: ...
9
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 ...
14
votes
4answers
21k views

Simple builder pattern implementation for building immutable objects

This is a builder pattern implementation to build immutable Person objects: Person class ...
1
vote
0answers
120 views

Fluent method arguments validation

I've put together a small fluent utility class for argument validation. Part of the code looks as follows: ...
2
votes
0answers
302 views

PHPSpec, testing code that uses fluent mock

I've just completed writing a spec for a Doctrine2 repository. The repo contains only one method so far, the spec for which takes in an OAuth Identity token object (that contains an ID that matches up ...
5
votes
2answers
178 views

Find attribute on class property

Since reading Robert Martin's book "Clean Code" I have been inspired to revisit and refactor some of my code to break it down into succinct methods and small specialised classes. Given the need to ...
3
votes
1answer
802 views

Css builder and parser

As part of a larger project I've created recently a simple CssBuilder and CssParser. It's composed of three classes and can ...
7
votes
3answers
196 views

Fluent API for creating random integer arrays in Java

Now I have this fluent API for creating random integer arrays. I can say that I want an array of particular length, having a particular minimum/maximum values and using a particular (or default) ...
1
vote
1answer
239 views

RPG Character with fluent interface

(Follow-up on RPG Character Builder) This implements a fluent interface for RPG game characters. Is this a valid implementation? There are 3 characters: Paladin, <...
5
votes
1answer
75 views

Attempting a fluent API for creating random int arrays

I have attempted doing a fluent API for creating random int arrays, and the following is what I came up with: fluent_arrays.h: ...
7
votes
1answer
3k views

Fluent Repository/QueryBuilder

I've been toying around making my repositories a bit more fluent for a while. I was ending up with crazy long method names when I had to query on multiple conditions. So I've been working on a way to ...
7
votes
2answers
441 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 ...
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 ...
8
votes
1answer
865 views

Fluent interface for manipulating employee records

I wanted to try experimenting with fluent interface design in the C programming language. That's why I wanted to ask you, Dear Code Review users, comments on the way I have implement this simple ...