Hello all,
I have the following class which I'm fighting over how to implement. The question is whether or not it makes sense to have a private collection item, in this case an arraylist, a a member. I am well aware it is considered best practice to have getters and setters for any class members, but in this case having a getter and setter would require re-implementing (or rather duplicating) large amounts of the ArrayList functionality.
Example class:
public class Email()
{
private ArrayList<String> To;
private ArrayList<String> Cc;
private ArrayList<String> Bcc;
...
}
I assume the answer is I should indeed implement getters and setters for these arrays? Is there some approach I haven't thought of regarding handling this type of situation? The easy solution to managing these lists is to set the private modifiers to public and check the array data is valid on calling methods, but is this right? Can anyone point me in the direction of other SO questions, design patterns etc I should consider?