Home

      Hosting      Domains       Support       Contacts

 

 

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.

·   Use open source frameworks which are established and tested.

·   Learn Collections and use them correctly. Use "lightweight" collections and avoid "heavyweight" collections where synchronization is not required.

·   Use constants where possible by using static final in the variable declaration.

·   Use Enum instead of integer constants. Enums are more flexible and are typesafe.

·   Avoid casting and using instanceof

·   Use synchronized methods instead of code blocks.

·   Avoid synchronized calls within a synchronized method or code block.

·   Do not recalculate constants inside a loop.

·   "Fast Fail" - If a method fails, or throws an exception have it exit the loop quickly. Break loops early.

·   Never use String or StringBuffer for parsing characters. Use a character array.

·   Try to set the StringBuilder or StringBuffer to the size required, or maximum size required during initialization to prevent a performance penalty while resizing.

·   Avoid using 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 objects.

·   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 | Hosting | Domains | Support |  Contacts |
|
Terms & Condition | Privacy Policy |


 

Copyright © 2005 by HostItWise.com Read our Copyright. All rights reserved.

GrdTuned.com | LasX.com | berberdecor.com Pouf Tea Glasses | AdvancedGarageDoorInc.com | BidoBee.com | RushRash Inc | Garage Door Repair