Advertisement
Home arrow Java Articles arrow J2EE EJB arrow J2EE Best Practices & Performance Tips
J2EE Best Practices & Performance Tips E-mail
Written by sunil boricha   
Article Index
J2EE Best Practices & Performance Tips
1. Always use MVC.
2. Apply automated unit tests
3. Develop to the specifications
4. Plan for using J2EE security
5. Build what you know.
6. Always use Session Facades
7. Use stateless session beans
8. Use container-managed transactions.
9. Prefer JSPs for presentation
10. store only as much state as you need
11. turn on dynamic caching
12. Prefer CMP Entity beans

related links

1. Always use MVC.

Cleanly separate Business Logic (Java beans and EJB components) from Controller Logic (Servlets/Struts actions) from Presentation (JSP, XML/XSLT). Good layering can cover a multitude of sins.

This practice is so central to the successful adoption of J2EE that there is no competition for the #1 slot. Model-View-Controller (MVC) is fundamental to the design of good J2EE applications. It is simply the division of labor of your programs into the following parts:

Those responsible for business logic (the Model -- often implemented using Enterprise Java™Beans or plain old Java objects).
Those responsible for presentation of the user interface (the View -- usually implemented with JSP and tag libraries, but sometimes with XML and XSLT).
Those responsible for application navigation (the Controller -- usually implemented with Java Servlets or associated classes like Struts controllers).
There are a number of problems that can emerge from not following basic MVC architecture. The most problems occur from putting too much into the View portion of the architecture. Practices like using JSP tag libraries to perform database access, or performing application flow control within a JSP are relatively common in small-scale applications, but these can cause issues in later development as JSPs become progressively more difficult to maintain and debug.

Likewise, we often see migration of view layer constructs into business logic. For instance, a common problem is to push XML parsing technologies used in the construction of views into the business layer. The business layer should operate on business objects -- not on a particular data representation tied to the view.

However, just having the proper components does not make your application properly layered. It is quite common to find applications that have all three of servlets, JSPs, and EJB components, where the majority of the business logic is done in the servlet layer, or where application navigation is handled in the JSP. You must be rigorous about code review and refactoring to ensure that business logic is handled in the Model layer only, that application navigation is solely the province of the Controller layer, and that your Views are simply concerned with rendering model objects into appropriate HTML and Javascript.



 

Sponsored

Login / Logout


//SPONSORED
© 2004-2009 Anil Kumar Kuchana SkillFox.com