Android Best-Practices and Notes

Self-note: Best approaches and best practices when developing Android applications

1. Use the parcelable as a data transfer mechanism instead of passing extras. Easier maintenance and higher readability for the cost of a couple lines of codes.
2. Offload all non-UI codes to non UI-threads (UI thread = Main thread). Any application must have at least two threads running.
3. Cache object instances whenever possible (Object Pool pattern)
4. List adapters should never perform expensive computations.
5. Realize the power of setTag, and never overlook the benefit of using ID resources
6. Leverage the power of Intents and receivers for internal message passing within an application.
7. Use soft references whenever possible, especially when dealing with memory intensive objects.
8. Be extra careful with static members they can cause memory leaks if not handled correctly.
9. Solidify UX and UI designs prior to any coding.

Notes:
BroadcastReceivers run on the Main thread.


About this entry