If you look at the test cases, the code is much less verbose and better readable.
Well, you separated each method call onto a separate line, so, it'd
look basically the same without chaining? If only all chained API
consumers followed your approach...
To be clear: what I dislike about chaining is it creates ambiguity
in how you write the code that consumes our APIs.
You().can().do().this(). Or, you().
this(). Or maybe you().can().
Ambiguity is very bad, especially in open-source dev: it invites
bikeshed wars, harming communities by dividing them, spending precious
time debating what from the outside would seem like trivial
If somebody wants to change this, he can do this in another issue called "remove all builders from Lucene"
The first API I would fix is IndexWriterConfig; its setters should not
be chainable, because now we get code like this:
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMaxBufferedDocs(2).setMergePolicy(newLogMergePolicy()));
Code is already hard enough to read... we should not make it even
harder by enabling big hard-to-read compound expressions like this.
This phenomenon is [unfortunately] human nature, and also well outside
of software development; see
http://en.wikipedia.org/wiki/Parkinson's_Law_of_Triviality ... the
less important the ambiguity the more brutal the bike shed wars will
be. You see this also in Theodor Geisel ("Dr Seuss")'s delightful
Sneetches (the stars on their stomachs), his Butter Battle Book (which
side to butter the bread on), which end of the egg to crack (the
Lilliputians in Gulliver's Travels), etc. It's not an uncommon
Battles over code styling is a great example of this phenomenon, and
fortunately we long ago adopted a standard for Lucene so we don't
argue (much!) about code style. There is one way and there is no
(little!) ambiguity left.
So I don't want to add any more chainable methods in Lucene. It
creates an unnecessary ambiguity and I don't like where that will lead
us. We should reduce ambiguity whenever we can: there should
generally be one obvious way to do something.