L
lemmi
Hi,
I have a question regarding the usage of variable arguments (VarArgs).
I am developing a framework and several of the classes in this
framework allow the developer to 'add' objects to them. One way of
implementing this is by passing a collection, an array, or a variable
argument. Is there a best practise on how to implement this?
Example:
Option 1: addMyObjects(Collection<MyObject> objects);
Option 2: addMyObjects(MyObject[] objects);
Option 3: addMyObjects(MyObject... objects);
I like option 3 because this way the developer can pass a single
object very easily without the need of creating an array.
Your thoughts?
--Dirk
I have a question regarding the usage of variable arguments (VarArgs).
I am developing a framework and several of the classes in this
framework allow the developer to 'add' objects to them. One way of
implementing this is by passing a collection, an array, or a variable
argument. Is there a best practise on how to implement this?
Example:
Option 1: addMyObjects(Collection<MyObject> objects);
Option 2: addMyObjects(MyObject[] objects);
Option 3: addMyObjects(MyObject... objects);
I like option 3 because this way the developer can pass a single
object very easily without the need of creating an array.
Your thoughts?
--Dirk