3 ms·
"Fluent interfaces" are nothing new and can be (and are in some projects) used in Java. When done correctly code completion works fine. As to whether they're
by TacticalCoder 3y ago
"Fluent interfaces" are nothing new and can be (and are in some projects) used in Java. When done correctly code completion works fine.
As to whether they're worth the addition trouble or not, I sure as heck don't know.
But it's definitely nothing out of the ordinary.
blobs = createBlob()
.withinRange(min,max)
.excluding(a,b,c)
.asArray()
There are variations, for example where only the last call actually creates, say, a Blob array and where every intermediate call produces something only allowing the next method to be called, so that the IDE autocompletes nearly everything for you and where you won't be able to compile if you miss a single call.
Don't know if the following link is any good but "fluent interfaces" are 15 years old stuff at least by now I'd say:
https://java-design-patterns.com/patterns/fluentinterface/#explanation https://java-design-patterns.com/patterns/fluentinterface/#e...
- rogerkeays 3y agoHow do you do the same thing to java.lang.String?
- ivan_gammel 3y agoA class MyStringBuilder with domain-specific fluent interface can do the job perfectly.
- rogerkeays 3y agoand a MyStringBuilderInterfaceProxyFactory too of course
- ivan_gammel 3y agoHate towards design patterns is a typical sign of not understanding them. Having a builder class to construct a certain subset of generic objects is a normal design practice, so your irony does not look appropriate and does not contribute to the discussion.
- rogerkeays 3y agoOK, sorry.