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
4
votes
4 answers

How do I write my wrapper class to use partial generic type inference?

This is related to this question. I'd like to create a generic wrapper class: public abstract class Wrapper { internal protected T Wrapped { get; set; } } With the following extensions: public static class WrapperExtensions { public…
3dGrabber
  • 4,710
  • 1
  • 34
  • 42
4
votes
3 answers

C# Lambda+Extensions+Fluent - How Would I Do This?

I want to be able to create "Transformation" classes that take a given object, perform a series of transformations on it (i.e. change property values) and keeps track of the transformations performed. The transformation performed will vary based on…
ctorx
  • 6,841
  • 8
  • 39
  • 53
4
votes
1 answer

How to find which Table is mapped by fluent API?

I need to find which table is mapped to an EntityTypeConfiguration class. For example: public class PersonMap : EntityTypeConfiguration { public PersonMap() { ... this.ToTable("Persons"); .... …
Saber
  • 2,440
  • 1
  • 25
  • 40
4
votes
2 answers

How do I get access to Castle Windsor's Fluent Interfaces API?

I've been having tons of problems getting the non-xml configuration for Castle Windsor set up working properly. In the meantime I've seen more and more people giving advice via the Windsor Container fluent interface. I've been Gooogling about for…
George Mauer
  • 117,483
  • 131
  • 382
  • 612
4
votes
3 answers

Recursive class definitions in Python

I am experimenting with fluent interfaces in Python. An example of a fluent sql query generator would look something like this in usage: sql.select('foo').select('bar').from('sometable').tostring() I quickly realized that the ability to define…
Ries
  • 2,844
  • 4
  • 32
  • 45
4
votes
5 answers

Which is more fluent - longer or shorter syntax?

I am trying to create my first fluent interface and I was just wondering what other poeple thought was more fluent and which one they would prefer to…
vdh_ant
  • 12,720
  • 13
  • 66
  • 86
4
votes
3 answers

Fluent interface pattern and std::unique_ptr

I am playing with the fluent interface pattern. First, I wrote something like that: class C { public: C() { } C* inParam1(int arg1){ param1 = arg1; return this; } C* inParam2(int arg2){ param2 = arg2; return this; } private: int…
Cristiano
  • 856
  • 10
  • 24
3
votes
1 answer

Are fluent interfaces described by context free or regular grammars?

I'm toying around with fluent interfaces in the style of Martin Fowlers text, and I'm wondering if the grammar they are describing is context free or regular? I'm talking about interfaces such as this: var car = new…
Dervall
  • 5,736
  • 3
  • 25
  • 48
3
votes
1 answer

Entity Framework 4.1 Code First - How to create two different relationships between two tables

I need to create a relationship where I have a user table that links to an address table. The problem is that I need the address table to also store historic addresses. It is also possible that a user might not have an address at all. public class…
3
votes
5 answers

How do I refactor chained methods?

Starting with this code: new Person("ET").WithAge(88) How can it be refactored to: new Person("ET", 88) What sequence of refactorings needs to be performed to complete the transformation? Why? Because there could be hundreds of these, and I…
Bjorn Reppen
  • 22,007
  • 9
  • 64
  • 88
3
votes
1 answer

how to develop sql query generator via Fluent interface?

i saw a article how to write a class which is a useful. the Class generates sql query via Fluent interface . But i am googling now but i can not find this excellent article. Do you know this article link :( or any other advise article or codes. Best…
loki
  • 2,926
  • 8
  • 62
  • 115
3
votes
1 answer

Best way to de-fluent an API?

I'm extending Fluent NHibernate for better use with F# (namely, quotation support), and want some feedback on de-fluenting the API. F# requires that return values be used, unless they are type unit. So this ends up terminating every line with "|>…
MichaelGG
  • 9,976
  • 1
  • 39
  • 82
3
votes
2 answers

Fluent API, Annotations and EF 4.1

Would somebody please guide me towards links that explain Fluent API and Annotations when using EF 4.1 code first please? The more in depth, the better. Thank you so much for your help in advance!
SimpleUser
  • 1,341
  • 2
  • 16
  • 36
3
votes
1 answer

Return generic of unspecified type

Is it possible to create a function that returns a generic of unspecified type, like this? Public Function Create(ByVal type As Type) As DeserializationHelper(Of ) Dim DynamicHelper = GetType(DeserializationHelper(Of )).MakeGenericType(type) …
Brian MacKay
  • 31,133
  • 17
  • 86
  • 125
3
votes
2 answers

Dependancy Injection and Fluent APIs - running into some problems

I am writing a fluent interface that is used like the following: xmlBuilder .CreateFrom() .DataSet(someDataSet) //yes I said Dataset, I'm working with a legacy code .IgnoreSchema() .Build The IgnoreSchema() method, could be…
Matt
  • 14,353
  • 5
  • 53
  • 65