C 2H A P T E R 2

Tuning Your Application

This chapter provides information on tuning applications for maximum performance. A complete guide to writing high performance Java and Java EE applications is beyond the scope of this document.

This chapter discusses the following topics:

“Java Programming Guidelines” on page 27

“Java Server Page and Servlet Tuning” on page 29

“EJB Performance Tuning” on page 32

Java Programming Guidelines

This section covers issues related to Java coding and performance. The guidelines outlined are not specific to Enterprise Server, but are general rules that are useful in many situations. For a complete discussion of Java coding best practices, see the Java Blueprints.

Avoid Serialization and Deserialization

Serialization and deserialization of objects is a CPU-intensive procedure and is likely to slow down your application. Use the transient keyword to reduce the amount of data serialized. Additionally, customized readObject() and writeObject() methods may be beneficial in some cases.

Use StringBuffer to Concatenate Strings

To improve performance, instead of using string concatenation, use StringBuffer.append().

String objects are immutable—they never change after creation. For example, consider the following code:

27

Page 27
Image 27
Sun Microsystems 820434310 manual Java Programming Guidelines, Avoid Serialization and Deserialization