Efficient Android development:
Principles: 1. Do not do unnecessary things; 2. save memory usage as much as possible
- Avoid creating objects as much as possible
- Use your own method,
Such as string. indexof (), String. lastindexof (), multiplication of its own method
- Use virtualization is better than use interfaces.
In embedded development, calling through interface reference takes two times over virtual time, for example, map map1 = new hashmap () and hashmap MAP2 = new hashmap (); in embedded development, hashmap is recommended to create objects. Similarly, list = new arraylist () and arraylist = new arraylist () are also recommended.
- Static is better than virtual:
If you do not need to access the external object, make your method a static method and it will be called more quickly because it does not require a false function to direct the table.
- Avoid using the internal get and set methods as much as possible. We should use the get and set functions for external calls and directly call the internal functions.
- Buffer property call:
For (INT I = 0; I <this. mcount; I ++) {dumpitem (this. mitems [I])} should be written as follows:
Int COUNT = This. count; item [] items = This. mitems; For (INT I = 0; I <count; I ++) the {dumpitems [items [I]} principle is that you should not call a class method for the second time in the for statement.
- Declare final Variables
- Exercise caution when using the incremental for loop statement, mainly because an object is created here.
- Avoid Enumeration type,
- Use package space through inline classes