java - collection vs list vs arrays as return type for EJB method -
java - collection vs list vs arrays as return type for EJB method -
i told collection should preferred list homecoming value of ejb method. argument in general collection more generic i.e. gives alter underlying info construction without impacting clients. , if flexibility want have designer using collection create improve sense. wouldn't create more sense homecoming array instead of collection?
and performance impacts if any?
thanks in advance.
prefer collections on arrays; utilize generics use interfaces instead of concrete classes
then have 4 options: list, set, collection , iterable. there depends semantics want include.
set will clients need random access it? list will clients need modify (add, remove) (without above 2 characteristics)? collection will clients need iterate it? iterable if it's web service doesn't matter - serialized same way. (note: there collection interfaces more specific semantics: queue, deque, map, bag, multiset, etc. - obvious when need homecoming them)
java java-ee collections ejb
Comments
Post a Comment