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. The phrase was first coined by Eric Evans and Martin Fowler.

Martin Fowler's explanation on what he considers to be the proper way to design fluent interfaces can be found at http://www.martinfowler.com/bliki/FluentInterface.html.

Related concepts:

437 questions
0
votes
0 answers

How to create a Fluent Interface that works in specific order

Hello i am trying to create a fluent API for an object.I create a builder object that will get its dependencies and then i will build the resulting object. The problem is that i need to perform some async operations using those dependencies to be…
Bercovici Adrian
  • 8,794
  • 17
  • 73
  • 152
0
votes
2 answers

How to make a field set-able only inside extension method

Hello i want to be able to set the a of a field of an object only in an extension method. I would want that this field to either be completelely private , or be just get-able from outside: public class Myclass { private int…
Bercovici Adrian
  • 8,794
  • 17
  • 73
  • 152
0
votes
1 answer

Get keys from nested JSONObject fluently

I'm trying to extract a value from a nested JSONObject, say "id". I'm using org.json.simple package and my code looks like: JSONArray entries = (JSONArray) response.get("entries"); JSONObject entry = (JSONObject) entries.get(0); JSONArray runs =…
Eric Hung
  • 512
  • 8
  • 23
0
votes
3 answers

Pros and Cons of Fluent and XML Configuration

If you we're about to start a new project with some third party libraries (logging, orm, di, whatever), would you prefer to configure all this libraries via programming with fluent interfaces or with XML files? Would you use a library that only…
goenning
  • 6,514
  • 1
  • 35
  • 42
0
votes
2 answers

How to build a sequence in the method calls of a fluent interface

Hi I would like to build a fluent interface for creating am object some sort of factory or builder. I understand that I have to "return this" in order to make the methods chainable. public class CarBuilder { public CarBuilder() { car…
silverfighter
  • 6,762
  • 10
  • 46
  • 73
0
votes
1 answer

How to get the autocomplition working correctly for inherited methods in PhpStorm?

There are two classes defined as follows: class Foo { private $aaa; public function setAaa(Aaa $aaa): self { $this->aaa = $aaa; return $this; } } class Bar extends Foo { private $bbb; public function…
automatix
  • 14,018
  • 26
  • 105
  • 230
0
votes
1 answer

Is it possible to detect if fluent interface was called for the first time?

Let's say I have a class: class A { public A fun() { System.out.println("a"); return this; } } And a scenario: A a = new A(); a.fun().fun().fun().fun(); a.fun().fun(); Is it somehow possible to print additional message…
xinaiz
  • 7,744
  • 6
  • 34
  • 78
0
votes
1 answer

EntityFramework FluentAPI mapping issue

I have the following code: namespace DynamicAssembly { using System; using System.Collections.Generic; using System.Collections; using System.Data.Objects; using System.Data.EntityClient; using System.Data.Entity; using…
bogdanbrudiu
  • 534
  • 9
  • 32
0
votes
1 answer

Fluent API with inheritance for validators - input validator instance seems identified as parent class

I'm writing a fluent API to validate key:value pair in a Map. I have a hierarchy of validator types. I referred to one answer from Fluent API with inheritance and generics. public interface IValidator { IValidator assertValue(String key, String…
Lazysheep.wang
  • 129
  • 1
  • 2
  • 12
0
votes
0 answers

Fluent API Method Call Chain - Use Reflection and Attributes to handle calls (C#)

I have a fluent API which I am trying to add another implementation for by passing in an enum to determine which object will be created and delegated to behind the scenes. It's for a UI testing framework, the fluent calls look like…
thisextendsthat
  • 1,266
  • 1
  • 9
  • 26
0
votes
0 answers

Is there a fluent way to continue from FluentIterable.index?

FluentIterable.index returns an ImmutableListMultimap, which ceases to be fluent. That means if I want to transform the existing map I will have to wrap the entire thing in another FluentIterable again, and the ugliness that results defeats the…
user69715
  • 825
  • 9
  • 15
0
votes
0 answers

Fluent API with multiple generic parameters and inheritance

I am trying to implement a fluent API that contains specialized derived classes and I am using the Derived extends Base method to obtain this parameter as Derived from base methods, but it doesn't seem to work with multiple generic…
Jezor
  • 3,253
  • 2
  • 19
  • 43
0
votes
1 answer

wrong number of arguments error while building a chainable ruby api

In my gem I have a class called Client that I want to operate like this: client = Client.new client.content_type('pages').content_type That means I want to set a property and then expect to immediately get it back in the same chain. This is what I…
Amit Erandole
  • 11,995
  • 23
  • 65
  • 103
0
votes
1 answer

Entity Fluent API - Compost Unique Index

Has there a way to create a compost unique index in fluente api based on some value ? Ex: string code { get; set; } bool active { get; set; } Property(x => x.code) .HasMaxLength(6) .HasColumnAnnotation( …
Lucas Freitas
  • 1,016
  • 4
  • 16
  • 37
0
votes
2 answers

fluent table display/retrieve item from another model (Icollection) (related table) in html

I have 2 tables Actors, Movies var Movie = new List { new Movie{MovieID=1,Title="Chemistry",Date="2013-09-01", Budget=10000, Actors = new List() }, new Movie{MovieID=2,Title="Chemistry…
streamc
  • 676
  • 3
  • 11
  • 27