Hello,
[Sorry but work is proprietary so I cannot give details of objects]
I am working on a Java application with a colleague. I am doing the client side and he is writing the server code.
The application displays a table of X objects. The columns of the table show some of X's attributes. In addition we have a column that shows a count of Y for each X. (Association is many-to-one Y to X and one way, Y has a reference to its parent X).
The count of Y is not an attribute of X but is obtained via a query on the DB.
I am using a TableModel so it would obviously be easier to use X objects as the model for the table. But since the Y count is not an attribute of X I will need to create a container object to hold an X plus a count. This is rather annoying as it adds a class that seems unnecessary.
I suggested to my colleague that he add an extra field to X plus a getter:
private void Map info = new HashMap();
This would make the model objects X more flexible. I can store any state I need at any time in the client without affecting the main attributes of the model which are specific to the nature of X. The keys would only be defined in the client so the model would not be polluted.
He has refused because he feels that the model objects should only model the domain and the extra field is not related to the domain objects and so should not be added. He thinks that the client should handle this.
Both viewpoints seem to have merit so I would be interested in what other readers think/feel about this.
Thanks,
Tim