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.
47 questions
1
vote
0
answers
86
views
Dependency Injection helper fluent UI
I am coding a NuGet package heavily inspired by Scrutor. I wanted to simplify Scrutor's fluent interface and improve its attribute-based class registration.
Thus, I'd like to gather some opinions and ...
3
votes
0
answers
400
views
Fluent VBA: Two (Almost Three) Years Later
Part 1 - A fluent unit testing framework in VBA: A fluent unit testing framework in VBA
Part 2 - Fluent VBA: One Year Later: Fluent VBA: One Year Later
Two (almost three) years have now passed since I ...
1
vote
1
answer
69
views
Comparing a weak fluent API with a strong fluent API in Java [closed]
I have this simple POJO:
...
1
vote
1
answer
554
views
Creating complex object step by step
Builder pattern separates object construction from its representation
I have to generate username and password for the Account class. Since this operation is a bit ...
4
votes
0
answers
235
views
Fluent VBA: One Year Later
A little over a year ago, I asked for feedback on Code Review for a unit testing framework I created in VBA. Development of this project has been off and on for the past year. Sometimes I wouldn't ...
2
votes
1
answer
385
views
Dart Ioc Container
This package is on pub dev here
It's on Github here
...
0
votes
2
answers
132
views
Instantiating Person objects using the builder pattern
I'm trying to make a safe builder using Kotlin that can be partially built and then copied, perhaps multiple times, to avoid repetition. Note that the properties that are reused aren't always the same ...
12
votes
3
answers
3k
views
Chaining list operations in Python
I assigned the following contrived problem in a comparative programming languages course to give students practice with "streaming":
Write function that returns the top ten players by ...
1
vote
4
answers
249
views
Java Fluent Wrapper [closed]
My gut tells me this is poor practice, so, I thought I would ask for some feedback.
The goal here is to fake a fluent API design for any class without using reflection while keeping it as pretty as ...
1
vote
1
answer
2k
views
Builder pattern in C# supporting subclassing with nested classes [closed]
[Posted yesterday on Software Engineering, but was apparently "disappeared"...maybe better here]
Background: I am just starting to get my head around the idea of separating the domain model from the ...
7
votes
3
answers
3k
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 ...
0
votes
1
answer
163
views
Chaining ConstrainableSet<T> [closed]
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
1
answer
181
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
1
answer
378
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
1
answer
293
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 ...
1
vote
1
answer
169
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
1
answer
123
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
1
answer
167
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.
...
5
votes
0
answers
371
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 ...
3
votes
1
answer
110
views
Java builder for user contact information, with optionals
I have this simple builder here:
...
2
votes
2
answers
268
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 chaining ...
6
votes
1
answer
1k
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.
...
4
votes
0
answers
222
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
0
answers
875
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
3
answers
973
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
2
answers
404
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
3
answers
7k
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
2
answers
102
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
1
answer
220
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
1
answer
3k
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
3
answers
154
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
1
answer
222
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
0
answers
84
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 ...
3
votes
1
answer
168
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:
...
12
votes
3
answers
4k
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 ...
23
votes
4
answers
28k
views
Simple builder pattern implementation for building immutable objects
This is a builder pattern implementation to build immutable Person objects:
Person class
...
2
votes
0
answers
397
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
2
answers
1k
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
1
answer
1k
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
3
answers
295
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) ...
2
votes
1
answer
457
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, <...
7
votes
1
answer
1k
views
Finite State Machine supporting shortest path transitions
In our automated test framework, written in Java 8, there are different entities representing test data, having different states and transitions between them.
To model this behavior, I started to ...
5
votes
1
answer
120
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
1
answer
4k
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
2
answers
502
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
6
answers
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
1
answer
907
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 ...