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 not expose the data structure in an object while accepting a collection of items with named parameters?

Most of the time, we can replace a fluent interface with named parameters. class Cart { fun withItems(vararg items: Item) = this } fun aCart(): Cart { TODO() } class Item fun anItem(): Item { TODO() } fun main() { …
ibrahim koz
  • 537
  • 4
  • 15
0
votes
1 answer

Dynamically load Entity Configurations in EF CodeFirst

I need to create composite key with fluent API dynamically according to database schema. I google for the solution but can't find any. Any suggestion how to do that?
Soe
  • 91
  • 1
  • 7
0
votes
1 answer

2 properties pointing to the same class in EF code first

I have a discussion object which in it self has a ParentDiscussion and TopParentDiscussion: public class Discussion { [Key] public Guid ID { get; set; } public String Message { get; set; } public virtual…
Kevin Cloet
  • 2,956
  • 1
  • 19
  • 36
0
votes
1 answer

How to terminate last function in chaining method php

I got some problem and I don't know how to fix it. this is sample for the problem class DancingClass { private static $associate = []; private static $first; public static function first($param) { self::$first = $param; …
lucky
  • 1
  • 1
0
votes
1 answer

Windsor Fluent Interface Lifestyle

Are these equivalent syntaxes for setting component lifestyle? Component.For() .ImplementedBy() .LifeStyle.Is(LifestyleType.Transient) Component.For() .ImplementedBy() .LifeStyle.Transient
0
votes
1 answer

Double destructor call in C++

I'm trying to create an object-configurator using a fluent interface. Code: class Configurator { public: Configurator() { printf("Constructor.\n"); } ~Configurator() { printf("Destructor.\n"); printf("String:…
user1562
  • 3
  • 2
0
votes
1 answer

How can I map a data member from an inherited class in multiple classes at once using Entity Framework Code First (Fluent API)?

If I have a class, say Entity, from which I create multiple classes. How can I do something like map the TimeStamp data member from the default column type of datetime to datetime2(7). I can map it individually like so: protected override void…
Alec
  • 1,646
  • 3
  • 19
  • 35
0
votes
2 answers

Instantiate a generic class T object and return it

I'm working on java selenium tests and I am trying to setup a fluent/method-chaining design code: I have a generic button class that allows navigating from a page class to the other. Buttons are attributes of my pages classes. Method in the button…
0
votes
1 answer

Can you use navigation sub-properties in foreign keys using EF 4.1 fluent API?

Let's use a simple example: public class Employee { public int EmployeeID { get; set; } public ICollection Pays { get; set; } } public class Pay { public Employee Employee { get; set; } public int Year { get; set; } public…
Sean Gough
  • 1,721
  • 3
  • 26
  • 47
0
votes
0 answers

C++ It is possible to use Fluent Interface inside Fluent Interface?

I want to achieve API to client to look like this: (modifying subcomponents by using fluent interface) FluentMainComponent("|FluentMainComponent|") .setA() .SetText("fa2") .Activate() …
Asmozan
  • 125
  • 1
  • 8
0
votes
1 answer

This code was working but now I get a recurssion error from the counter in __getattribute__

I need help making my Query object not have a recursion error. To check the right amount of function have been chain-called I am adding a counter to get attribute that caused a recursion error. This wasn't happening when I hade only a few functions…
0
votes
0 answers

How to add potential owner for dynamic creation BPMN via API?

I'm trying to follow this document (https://docs.jboss.org/jbpm/release/7.3.0.Final/jbpm-docs/html_single/#_process_fluent_api) to use jBPM fluent api to create a process. But I'm wondering how to add potential owner for a task? I saw some document…
user3593261
  • 560
  • 4
  • 17
0
votes
1 answer

Entity Framework 4.1:is it preferred to annotate properties or to use Fluent API

As the title implies: what are the pros and cons using Annotations instead of the Fluent API (or reversed)?
0
votes
2 answers

EF 4.1 Fluent API dB first relationship mapping problem

I have the following tables, Product(pro_iIDX[PK], pro_sName) Manufacturer(man_iIDX[PK], man_sName) ProductManufacturer(pma_iIDX[PK], pma_iProductRef[FK], pma_iManufacturerRef[FK], pma_bAvailable) I have the following POCOs, public class…
0
votes
1 answer

How to create Find.Elements.By.Name(string name) in fluent API design?

Is this possible to create something like Find.Elements.By.Name(string name) using fluent api design pattern in c#? If so, how?
Jason
  • 1,680
  • 3
  • 13
  • 16