Coding Tips (J2ME)

xiaoxiao2021-03-06  44

Coding tips

The Following Tips Are ONLY SUGGES AND YOR MY NOT GIVE GAINS IN Performance, IT

Is to your owned judgment and discretion to use..

1. Use stringbuffer instead of string Because of the fact the string object can not

Be changed. Any Modification to a string variable is actually a new Object

CREATION.

2. Accessing Class Variables Directly Is Faster Then Using Setter and getter

Methods

3. USING LOCAL VARIABLES ARE More Efficient Then Instance / Class Variables

4. USING VARIABLES Are More Efficient The Arrays.

5. Avoid Synchronization in loops Because there is an an extra over head to lock and

Unlock Each Time the loop occurs

6. Counting Down in loops is faster the country up

7. Use compound operators like x = 1 INSTEAD O f x = x 1 Because Fewer Byte

Codes IS generated

8. REMOVE Constant Calculation in loops

9. Reuse Objects

10. Assign Null To Unused Objects, Especially Unused Threads

11. Try to use alleady Builtin Methods, for Example If You Want To Copy Data FROM

One Array to Another Use System.Arraycopy More Then Likely this Method Will

Be More Efficient Then the one you created yourself

转载请注明原文地址:https://www.9cbs.com/read-51812.html

New Post(0)