1
Suppose I am modeling a Paycheck. However, each entry in a Paycheck I chose to model as a ItemContracheque
. That is, to represent my Paycheck as a whole, I can use a simple list of ItemContracheque
.
Then came the doubt, if only a list of ItemContracheque
can represent an entire Paycheck, since it has no additional attribute, I still need to create this Paycheck object that would have only one attribute (a list of ItemContracheque
)?
What would be the most OO practice to adopt here? Create this object Counter check with only one attribute or represent a Paycheck using only a list of ItemContracheque
? And the main thing, why choose one over the other?
This modeling will be used in the return of one of the webservice methods I am making.
With Java codes to improve the issue:
public class Contracheque {
private List<ItemContracheque> itensContracheque;
}
or just use:
List<ItemContracheque> itensContracheque;
That is, it would define the return of my method: or an object Contracheque
or a List<ItemContracheque>
.
Thanks for the answer. I get it! On your questions: yes, there may even be other attributes, but to supply the need for what I need to do, they are not necessary. So you don’t have to put them on the object.
– Luiz
I still think it’s unlikely, but if you say...
– Maniero
Hahaha How much skepticism! I will accept yours as an answer, it was very satisfactory. Thanks for the help, bigown! ;)
– Luiz