Let's assume I have the following class:
public abstract class Client {
private String clientID;
private String clientFirstName;
private String clientLastName;
public Client(String ID, String firstname, String lastname)
{
this.clientID = ID;
this.clientFirstName = firstname;
this.clientLastName = lastname;
}
}
and the following Subclasses:
public class Domestic extends Client {
public Domestic(String ID, String firstname, String lastname) {
super(ID, firstname, lastname);
}
}
public class International extends Client {
private List<String> documents;
public International(String ID, String firstname, String lastname, List<String> documents) {
super(ID, firstname, lastname);
this.documents = documents;
}
}
Given that both subclasses have a different set of parameters, the International subclass requires a List of documents(passport, drivers license), while domestic doesn't. To me anyway, I don't believe the factory pattern is adequate because of the different constructor parameters, and the builder patter isn't necessary as all arguments are necessary, an there isn't that many of them. So is doing this okay?
Client international = new International(id, firstname, lastname, documents);
or if there is a specific method that I need to access in the International class:
International internationalObj = new International(id, firstname, lastname, documents);
Questions:
1. Is it mandatory to use the factory or builder pattern given this situation?
2. Is there a downside to doing to doing it without the factory or builder?