My Android Note
tránh tạo các đối tượng không cần thiết
sử dụng string buffer (multi thread) hoặc string builder cho việc append chiều chuỗi string
hai mảng a[] b[] tốt hơn so với (a,b)
Nếu bạn không cần truy xuất vào các biến của object. Có thể làm cho phương thức của bạn thành static. Lúc đó việc gọi hàm sẽ nhanh hơn khoảng 15-20%. Việc này cũng có một lợi thế nữa là method của bạn khi được gọi cũng không làm ảnh hưởng đến object
Use Static Final For Constants, const int BIT BETTER than enum
bên trong class thì bạn luôn luôn nên truy xuất trực tiếp vào biến (tránh gọi qua setter )
foreach > fori
cố gắng giảm thiểu độ sâu của layout
(nên dùng leakcanary)
sử dụng support percent thay layout weight
sử dụng okhttp (retrofit) hoặc voley thay cho apache httpclient mặc định
luôn luôn sử dụng proguard cho các bản release build
Sử dụng RxAndroid hoặc service, loader thay cho async
Use Optimized Datacontainers
SparseArray
SparseBooleanArray
SparseIntArray
SparseLongArray
LongSparseArray
Try to avoid static variables or objects as much as possible if they are not final constants. Static variables pose the threat of having references in other classes, which we might forget about and thus cause a memory leak