I have the following class that I'm struggling with how to implement it. The question is whether it makes sense to have a private collection, in this case an arraialist, a member. I know well that it is considered best practice to have getters and setters for any members of the class, but in this case having a getter and setter will require re-implementation (or rather duplication) of large amounts of ArrayList functionality.
Class Example:
public class Email { private ArrayList<String> To; private ArrayList<String> Cc; private ArrayList<String> Bcc; ... }
I guess I should really use getters and setters for these arrays? Is there some kind of approach that I have not thought about how to handle this situation? A simple solution to managing these lists is to set the private modifiers to the public ones and verify that the array data is valid on calls, but is this true? Can someone point me towards other SO issues, design patterns, etc. Should I consider?
user257111
source share