eclipse-collections icon indicating copy to clipboard operation
eclipse-collections copied to clipboard

JavaDoc: Factory classes description confusing about of() and with()

Open Chealer opened this issue 2 years ago • 3 comments

The JavaDoc for factory classes contains examples. For example, the description of org.eclipse.collections.impl.factory.Sets contains:

Mutable Examples:

MutableSet<String> emptySet = Sets.mutable.empty(); MutableSet<String> setWith = Sets.mutable.with("a", "b", "c"); MutableSet<String> setOf = Sets.mutable.of("a", "b", "c");

A reader will wonder how the last 2 examples (setWith and setOf) differ (besides names). It turns out they don't; they are merely synonyms.

I recommend to stick with a single form, or to indicate that they are synonymous (or at least, to describe the effect of each).

Chealer avatar Aug 21 '23 21:08 Chealer

I am working on this issue and here what I came to conclusion that the updated doc should be after describing effect of each.

 * //Creates an empty mutable set
 * MutableSet<String> emptySet = Sets.mutable.empty();
 * // Creates a mutable set containing the specified elements "a", "b", and "c"
 * MutableSet<String> setWith = Sets.mutable.with("a", "b", "c");
 * // Creates a mutable set containing the specified elements "a", "b", and "c" (synonymous with setWith)
 * MutableSet<String> setOf = Sets.mutable.of("a", "b", "c");
 * 

BrijeshPatra avatar Aug 22 '23 03:08 BrijeshPatra

Greetings @BrijeshPatra , Thanks, that's quite reasonable, but I would suggest:

 * // Creates an empty mutable set
 * MutableSet<String> emptySet = Sets.mutable.empty();
 *
 * // Equivalents which create a mutable set containing the specified elements ("a", "b" and "c"):
 * MutableSet<String> setWith = Sets.mutable.with("a", "b", "c");
 * MutableSet<String> setOf = Sets.mutable.of("a", "b", "c");
 * 

Chealer avatar Aug 22 '23 11:08 Chealer

Hello, @Chealer

Thank you for your prompt response and for addressing the documentation issue. I appreciate the changes made to improve the clarity of the documentation for Sets.mutable.

If you have any more questions or if there's anything else I can assist with, please feel free to let me know.

Best regards, Brijesh Patra

BrijeshPatra avatar Aug 22 '23 11:08 BrijeshPatra