Suppose I'm modeling a contracheque. However, each entry in a contracheque I chose to model as a ItemContracheque
. That is, to represent my Contracheque as a whole, I can use a simple list of ItemContracheque
.
Here is the question, if only a list of ItemContracheque
can represent a whole contracheque, since it does not have any more attributes, I still need to create this contracheque object that would only have one attribute (a list of% %)?
What would be the most OO practice to adopt here? Do you create this object with only one Contracheque or represent a Contracheque using only a list of ItemContracheque
? And the main one, why choose one instead of the other?
This modeling will be used to return one of the webservice methods I'm doing.
With Java code to improve the issue:
public class Contracheque {
private List<ItemContracheque> itensContracheque;
}
or just use:
List<ItemContracheque> itensContracheque;
That is, this would define the return of my method: either an object ItemContracheque
or a Contracheque
.