Apps are an integral part of today’s digitized world and Android app development is a key activity for many companies. Given the immense competition in the apps’ realm, there are certain features that today’s apps have to possess. They must have most if not all of the following: fancy animations, complex transitions and custom views. They must also have a great user experience that is intuitive and easy to use on any device.

However, creating apps like this can be challenging for even seasoned developers. App development is essentially a series of patterns, and great app developers know to avoid specific patterns when developing apps. Hopefully, at the end of this article, you will be aware of those patterns to avoid when developing an app. Here are some of the patterns to avoid Android development.

Patterns to Avoid Memory Churn

  • Try not to assign unnecessary objects
  • Using object pools and caches help to reduce churn
  • Be wary of the overhead of enums since a single reference to an enum occupies 4 bytes immediately

Patterns to Avoid Memory Leaks

  • Avoid leaking contexts in inner classes
  • Avoid leaking views inside activity
  • Avoid the use of non-static. Use static inner classes instead
  • Avoid the use of WeakHashmap as cache

Patterns to Avoid Lousy Performance

  • You want to stop blocking main Thread
  • Steer clear of needless invalidations that may generate a flow of invalidations
  • Stay away from nested weights in LinearLayouts
  • Try to make Customs views better
  • Try as must as possible not to create unnecessary objects
  • You need to deploy static Final For Constants (static 15%-20% faster)
  • Staying away from Primitives (Integer vs Float 2x slower)is a great idea.
  • Avoid Internal Getters/Setters (direct field access 3x faster)
  • Enhanced is a great option to use For Loop Syntax
  • You might want to try Package in place of Private Access with Private Inner Classes.
  • Be smart with your use of native methods.

Patterns to Avoid Overdraw

  • Try to simplify your drawables
  • Be careful when setting alpha in your views
  • Exclude unused background from your views

Patterns for Custom Views

  • Try to keep it as simple as possible avoid unnecessary layouts and remove unnecessary calls to validate
  • Use merge tag as root in your layout
  • Add tag so you can easily reuse standard layouts
  • Avoid making allocations or massive operations in OnDraw
  • Creating your ViewGroup is a great idea
  • Use RecyclerViewinstead of ListView and GridView)

Patterns to Avoid ANRs

  • Indicate the progress being made by an app working in the background on a user’s input
  • Performance tools like Systrace and Traceview should be used to determine bottlenecks in the way the app responds
  • Try rendering the main view as fast as possible and show that the app loading is in progress if the app has a slow setup phase.

Conclusion

If you are looking to improve your Android app development skills that users find useful, then all you need is to use the information from this article. Developing efficient apps will become a walk in the park. When you are ready to release your app, let us help you ensure that your app is app store ready by ensuring high levels of performance.

Let's Get In Touch

We received your message and will contact you back soon.

Leave a Reply

Your email address will not be published. Required fields are marked *