Originally posted by red herring:
As I am writting my Beans I wonder whether you shouldn't use an ArrayList (or other collections) as properties of the Bean. The reason why is because I believe that the actual object contents of the ArrayList are hidden anyone else using the Bean. I would think it more appropriate to convert to a normal array before adding to your Bean. Doing this allows others to see what data type the property is. e.g.
class ExampleBean{
private ArrayList cars; //what is contained in this ArrayList?
private Ford[] cars; //it is clear what this is now.
//getters and setters here...
}
So, is it ok to use collections or is it best practice to convert to an array so that the datatype is clear to other developers?
Thanks heaps.
HI Felix,
I can see where you're coming from. Arrays are more normative, and for a lot of reasons(distributed computing being one), they are the better choice. But. ArrayLists are also useful for these sorts of situations, and not really a terrible answer.
The bottom line, IMO, is this. If you're the person who sets the standards for your team, and your efficiency doesn't suffer too much, do what you think is right
All best,
M