I started writing a fluent interface and took a look at an older piece Martin Fowler wrote on fluent interfaces (which I didn't realize he and Eric Evans coined the term). In the piece, Martin mentions that setters usually return an instance of the object being configured or worked on, which he says is a violation of CQS.
The common convention in the curly brace world is that modifier methods are void, which I like because it follows the principle of CommandQuerySeparation. This convention does get in the way of a fluent interface, so I'm inclined to suspend the convention for this case.
So if my fluent interface does something like:
myObject
.useRepository("Stuff")
.withTransactionSupport()
.retries(3)
.logWarnings()
.logErrors();
Is this truly a violation of CQS?
UPDATE I broke out my sample to show logging warnings and errors as separate behaviors.
logWarningsAndErrors
return anything? If not, then is it really a fluent interface? – TetrastichouslogWarningsAndErrors
returns an interface that I can add additional behaviors to. – Euphonium