Hi Everybody,
Firts :
I looked a topic on this and I didn't find.
----------------------------------------------------
I have an application that it has many DTO's (TO's/Model's):
Tables:
Company
-------------
IDCompany_1 = PK -> ID
IDCompany_2 = PK -> REGISTER DATE
Desc
Phone
-------------
and
Employee
-------------
IDCompany_1
IDCompany_2
IDEmployee
Desc
Address
-------------
I have:
================================================
A
================================================
public class CompanyDTO extends CompanyPKDTO
{
private String desc;
private String phone;
//get and set
}
public class CompanyPKDTO implements Serializable
{
private Integer IDCompany_1;
private Date IDCompany_2;
//get and set
}
public class EmployeeDescDTO extends EmployeeDTO
{
private String descCompany;
private String phoneCompany;
//get and set
}
public class EmployeeDTO extends EmployeePKDTO
{
private String descEmployee;
private String addressEmployee;
//get and set
}
public class EmployeePKDTO implements Serializable
{
private Integer IDCompany_1;
private Date IDCompany_2;
private Integer IDEmployee;
//get and set
}
================================================
B
================================================
public class CompanyDTO implements Serializable
{
private Integer IDCompany_1;
private Date IDCompany_2;
private String desc;
private String phone;
//get and set
}
public class EmployeeDTO implements Serializable
{
private Integer IDEmployee;
private String descEmployee;
private String addressEmployee;
private CompanyDTO companyDTO;
//get and set
}
===========================================================
However, situation exists I'll only need the ID's of the company and I won't need 'desc' and 'phone' of the Company.
===========================================================
You must consider all aspects of development, performance and memory;
And considering, I can consult a list(ArrayList) of EmployeeDTO.
Which is better, 'A'or 'B' ?
I think the 'B', but I'm opening this topic to take off doubts.
Thanks......!!!