Assume that I have AnimalData and AnimalListData:
<bean class="com.chang.data.AnimalData">
<property name="name" type="java.lang.String"/>
<property name="weight" type="java.lang.Integer"/>
</bean>
<bean class="com.chang.data.AnimalListData">
<property name="animals" type="java.util.List<com.chang.data.AnimalData>"/>
</bean>
If I create ZooData with a list of AnimalData, is it a better to use a List of Data objects (Approach #1) or a ListData object (Approach #2)? When should I use Approach #1 or Approach #2? How about for WsDTOs? Is the case the same?
Approach #1:
<bean class="com.chang.data.ZooData">
<property name="animals" type="java.util.List<com.chang.data.AnimalData>"/>
</bean>
Approach #2:
<bean class="com.chang.data.ZooData">
<property name="animals" type="com.chang.data.AnimalListData"/>
</bean>
It doesn't make a great deal of difference in my opinion, so some of this is personal preference. The thing I would think about is: in approach 2 you have to do zooData.getAnimals().getAnimals(), whereas in approach 1 it is zooData.getAnimals(). The same applies for the DTOs point. So approach 1 seems more intuitive to me .....