Question: List as much as you can
all the trick/programming recommendation that we can use
when PERFORMANCE is essential in Java?
Answers: The following are the tricks which can be
helpful in performance in Java..
Always use the simplest classes possible to get
the Job Done.
Never code your own frameworks unless the
performance is lacking. Reuse code and frameworks.
open source frameworks which are established and tested.
Collections and use them correctly. Use "lightweight"
collections and avoid "heavyweight" collections where
synchronization is not required.
constants where possible by using
static final in the variable declaration.
Enum instead of integer constants. Enums are more
flexible and are typesafe.
Avoid casting and using
Use synchronized methods instead of code blocks.
synchronized calls within a synchronized method or code
Do not recalculate constants inside a loop.
Fail" - If a method fails, or throws an exception have
it exit the loop quickly. Break loops early.
StringBuffer for parsing characters. Use a
Try to set the
StringBuffer to the size required, or maximum
size required during initialization to prevent a
performance penalty while resizing.
StringTokenizer if there is a
performance requirement. Use a more specific (custom)
tokenizer to split Strings. StringTokenizer is a generic
utility that is synchronized internally.
Avoid using generic object collections. Use
generics with collections to avoid having to cast
· Use a
LinkedList over an
ArrayList if there a large number of
insertions and deletions.
When given a choice use local interfaces and
local method calls on EJBs
Java Tutorial Home 1 2 3 4 5 6 7 8 9