[
https://issues.apache.org/jira/browse/LUCENE-3756?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13202741#comment-13202741
]
Uwe Schindler edited comment on LUCENE-3756 at 2/7/12 8:28 PM:
---------------------------------------------------------------
{quote}
Does anyone think the example above is more readable than the
non-chained alternative? Look at all our tests, where we inline the
creation/building of an IWC: can you find one where chaining actually
helps readability?
{quote}
The not-chaining does not help for readability, chaining makes it more
readable. You can format it like I did in the tests (actually, it was not me,
it was Eclipse - does it detect builders?). In contrast you can also write all
in one line without chaining.
So where, wtf, is the difference? Everybody can write the code as one like, so
I can write a full java class in one line, why not? I can on the opposite also
write all parts of a chaining api in separate lines and that's what I generally
do (look at my StringBuilders when I code something). Nobody forces me to do it
in the one or other variant.
In contrast, using the API with repeating the instance variable every time
makes it really unreadable, especially because the *important* parts are hidden.
If you like, I will ask my Eclipse to rewrite all tests to make chains in new
lines (if it can do this, because it did this when coding the test).
Uwe
was (Author: thetaphi):
{quote}
Does anyone think the example above is more readable than the
non-chained alternative? Look at all our tests, where we inline the
creation/building of an IWC: can you find one where chaining actually
helps readability?
{quote}
The not-chaining does not help for readability, it makes it more readable. You
can format it like I did in the tests (actually, it was not me, it was Eclipse
- does it detect builders?). In contrast you can also write all in one line
without chaining.
So where, wtf, is the difference? Everybody can write the code as one like, so
I can write a full java class in one line, why not? I can on the opposite also
write all parts of a chaining api in separate lines and that's what I generally
do (look at my StringBuilders when I code something). Nobody forces me to do it
in the one or other variant.
In contrast, using the API with repeating the instance variable every time
makes it really unreadable, especially because the *important* parts are hidden.
If you like, I will ask my Eclipse to rewrite all tests to make chains in new
lines (if it can do this, because it did this when coding the test).
Uwe
> Don't allow IndexWriterConfig setters to chain
> ----------------------------------------------
>
> Key: LUCENE-3756
> URL: https://issues.apache.org/jira/browse/LUCENE-3756
> Project: Lucene - Java
> Issue Type: Improvement
> Reporter: Michael McCandless
> Assignee: Michael McCandless
>
> Spinoff from LUCENE-3736.
> I don't like that IndexWriterConfig's setters are chainable; it
> results in code in our tests like this:
> {noformat}
> IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
> TEST_VERSION_CURRENT, new
> MockAnalyzer(random)).setMaxBufferedDocs(2).setMergePolicy(newLogMergePolicy()));
> {noformat}
> I think in general we should avoid chaining since it encourages hard
> to read code (code is already hard enough to read!).
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]