Well formed constructor | Java classes and keywords


Lazy instantiation

All EJB multi-object finders return enum (EJB 1.1) or Collection (EJB 2.0). The actual object is not instantiated until the object is needed. This pattern should be preserved in our EJB and AccessBean when returning relationship objects, for example:

AssociatedAccessBean[] getAssociatedBean() should be changed to

Enumeration getAssociatedBean() or Collection getAssociatedBean()

A similar pattern should be used in DataBean as well.

Re-use finder results

Finder methods go back to the database to obtain their results. Avoid calling the same finder to find the same results more than once in a transaction by saving the resulting access bean objects and re-using them until the transaction ends.