views:

34

answers:

2

I am making a website with GWT and using Hibernate to connect to the database.

Every time a user loads a page and it is required to grab information off the database. Is it better to have monolithic classes containing all the getters/setters for the tables, and select the information as needed, or is it better to have many different class maps that only loads the information needed for that page load?

Having the monolithic class is better because it is more easily cacheable, but I find that having smaller classes is more manageable.

+4  A: 

An object model should reflect the problem you're trying to solve, not the arbitrary way you've decided to partition the UI into pages.

Caching should be independent of the UI.

Model the objects (and the relational schema) to best reflect the problem at hand. Worry about the UI separately.

duffymo
+1  A: 

I will model the object according to the domain logic, not the UI. Put everything together just for the convenience of the UI loading, it will result in redundant properties in the object.

The hibernate entity object should act as a domain object first.

Simon