Julian Reschke wrote:
Marcel Reutegger schrieb:
because we didn't see a need for a Set. a collection is IMO sufficient. what is the benefit of a Set over a Collection for a client?

The client can rely on not having duplicates in it,

The client can rely on it anyway because the documentation says so. e.g. even a Set would allow a null value in general but getDependencies() will never return a collection with a null value. IMO the binding contract is the documentation, specifically when dealing with collection classes that are very general.

Using a Set would make sense when passing in a collection of objects and the callee doesn't want to accept duplicates.

> or alternatively,
> the producer doesn't need to take care not to produce them...

Using a Collection gives the producer the freedom to choose which implementation he wants to use. if there are just a couple of element an ArrayList is less expensive than a HashSet.

regards
 marcel

Reply via email to