davidmarquis/fluent-interface-proxy

Is it Fluent Interface or just Method Chaining?

Make42 opened this issue · 6 comments

Does this project provide a way to define real fluent interfaces or just method chaining builders?

"I've also noticed a common misconception - many people seem to equate fluent interfaces with Method Chaining. Certainly chaining is a common technique to use with fluent interfaces, but true fluency is much more than that." http://www.martinfowler.com/bliki/FluentInterface.html

What I mean by "method chaining" is something like

 Interface myclass = new MyClass().dothis("mytext").dothat("more text").add(5);

By fluent interface I mean an internal DSL that is able to give the using programmer an interface that limits his/her options to sensible once, thus implementing a grammer: http://blog.jooq.org/2012/01/05/the-java-fluent-api-designer-crash-course/ (possibly with method chaining, but method nesting is an alternative).

I'm not completely clear on your intent here... you seem to have a good understanding of how using Method Chaining supports designing Fluent Interfaces. Are you trying to suggest the project is misnamed or are you trying to better understand what the project is about?

I would like to understand what the project is about and/or what it supports. It is obvious to me that it builds builders that can be configured using method chaining. However I would like to know if the builders supports fluent interfaces.

(Fluent interfaces are not a subset of method chaining and method chaining is not a subset of fluent interfaces. Method chaining can be used for implementing a fluent interface).

If the project does not build builders that support fluent interface (meaning a grammar), then I would argue that the project is misnamed. However, until then, I just want to understand the project.

OK thanks for clarifying.

The project provides automatic implementations of Java Interfaces that are designed following the Builder pattern. It does this using dynamic proxies, hence the name fluent-interface-proxy (a Proxy for your Fluent Builder Interfaces).

I think you're confusing Java Interface (the language artifact) and Interfaces as a broader design terminology. (Like the word Interface in "API" - Application Programming Interface).

If I had known this possible confusion, maybe the project would have been named more around something like fluent-builder-proxy. :)

Let me know if improvements to the README could help clarify this... Pull requests are also always welcome.

Now, regarding your question:

However I would like to know if the builders supports fluent interfaces.

The project helps Java programmers quickly create Builders that use Method Chaining - which is, as you're disambiguating above, a way to create Fluent APIs - in order to build objects. The key thing is building objects... it is not expected to help you build Fluent Interfaces in general, these would be very specific and are better implemented manually. The library helps with the tedious and repetitive task of implementing (not designing) fluent Builders in Java.

When I have been talking about "interfaces", then I have been talking about the design pattern (design terminology), as in API. The same goes for this post. I realize now, that you have been talking about the Java interface.

I guess you chose the word "fluent" because it resembles "fluent english language"? This would also be an aspect of fluent interfaces (design pattern), but fluent interfaces (design pattern) also imply some sort of grammar. However, I give you that the English wikipedia article is not so clear on this as it could be - the German one is better, and the article of Martin Fowler is even clearer on this (see my earlier quote).

My impression is that "Fluent interface" is a standard expression which by now refers to the design pattern. The fact that you mention the wikipedia articles, which talks about the design pattern, is therefore misleading. I'd encourage you to take the wikipedia reference away and to rename your project or at least write a fist paragraph of the readme, that explaint that it's about implementing Java interfaces with a method chaining builder pattern (and not a fluent interface with a grammar).

Btw: Fluent interfaces are often not implemented manually. Examples:

  1. http://heinerkuecker.de/Fluent_Interface_Code_Generator_auf_Basis_einer_Grammatik.html
  2. https://github.com/Cascading/fluid
    But sometimes they are, as it has been done for http://www.jooq.org/
    All these examples have fluent interfaces which have a grammar.

Closing issue as being philosophical :)

That is okay :-D.