I have a field that can receive the physical or legal person, how do you model it? through interface, composition or inheritance?
I have the following class structure: Contacts (PF only) - belongs to a - > Company (PJ only) The contacts have several roles, such as: Seller, Owner, etc.
public class Contato {
private Empresa empresa;
/* ... */
}
public class Empresa {
private Set<Contato> contatos;
/* ... */
}
But I also have the following situation
public class MeuObjeto {
??? responsavel;
}
In these cases the person in charge can be a Contact (Physical) or a Company (Juridica). would not like to fall into Person's solution - > Individual, Person - > Legal person, I thought about using an interface, but it could end up growing too much. The question is, does anyone know any more patterns that can help in the logical modeling of this situation?
** Improving the question