Tuesday, November 15, 2005

I've been invloved in reviewing the code of our product and load testing and found out/realised some important practices that should be followed in J2EE projects. Here are few of them which are of course open for discussion,

Today I will list down some EJB related practices...

1. Never use the ejbConstructor for getting any work done (Typically resource initializations). The spec does not gurantee the call back of the constructor. Instead use the ejbCreate() method for any resource initilizations etc...Similarly use the init() method in Servletes.

2. Return PK in in ejbCreate() methods.

3. Use DTOs in ejbCreate() when there are too many parmas coming in.

4. Always use CMR (Container Managed Relations) to manage the relations. This will result in less code and straight forward finder methods thus improving code quality and performance.

5. Use the EJBHomeFactory pattern to reduce JNDI calls and cache EJBHomes.

6. Tune Stateless session beans instance pool size.Give maximum beans as equal to maximum number of client accesses.

7. Tune Entity beans instance pool size and instance cache size. Give maximum beans in pool as equal to number of maximum concurrent client accesses. Cache size must be equal to concurrent active clients accessing the bean.

Any comments or experience on these or any other ideas is mostly welcome.

Post a Comment