Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference Guide: Iteration patterns chapter has multiple issues in "Select and Reject patterns" section #1500

Open
Chealer opened this issue Aug 24, 2023 · 0 comments

Comments

@Chealer
Copy link

Chealer commented Aug 24, 2023

The Select and Reject patterns subsection of the chapter Iteration patterns of the reference guide contains a good number of issues. I've opted to report all of those I spotted in this ticket, but feel free to mark this as resolved once a first pass was done. If needed I will file individual tickets for those remaining.


The section opens with a quote:

Filter a collection to create a new collection: includes select, reject, and partition.

This quote's role is unclear, but it seems to be equally relevant to this subsection and the one which follows it.


The section continues:

Methods using the Select pattern return a new collection comprising those elements from the source collection that satisfy some logical condition. Reject is the inverse pattern, returning a new collection of elements that do not satisfy the condition. The condition is a boolean expression in the form of single-argument code block that implements the Predicate interface.

It would be more clear/exact to talk about a predicate than a "condition". In any case a predicate (or "condition") is not a boolean expression. While the predicate may be implemented using a boolean expression, a predicate is more generally an object. Moreover, such objects do not necessarily implement the Predicate interface (they can simply implement Predicate2). Finally, this is ambiguous since EC with a modern JDK provides 2 Predicate interfaces (org.eclipse.collections.api.block.predicate.Predicate and java.util.function.Predicate).


The second line of example #1 has spurious indentation (just like example #7). The third line would be more correct/clear as if <element> satisfies <condition>.


Example #3 does not indicate which Predicate class it refers to.


The section contains multiple examples using EC, but not all of them do. It would clarify to make each category distinguishable, perhaps by adding borders with different colors to their code blocks.


The section contains multiple examples, but there is no description of what any of them accomplishes. Either describing their effect or at least adding example values for collections would help. It should at least be possible to tell which are equivalent.


The order of examples seems counter-intuitive. Should #6 not come second?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant