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.

if internal api - decide based on characteristics of collection: does hold unique items? 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

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -