Journey To Performance Oriented Android Development Part 1

101 28
Performance metrics have good place in the designing of UX for any Android application development. Basically performance can be obtained with many ways, but micro-optimization is the best method to start if from the foundation stage. Albeit micro-optimization alone can't improve overall performance dramatically, you need to combine that with the selection of right algorithms and data structures. There are many good coding practices which can contribute greatly in code efficiency like, you need not to work that you don't need thus avoid unnecessary code from your Android development project. Same the way you should avoid unnecessary memory allocation since Android devices have limited memory as well as processing power.

As an Android programmer you will face greater difficulties in micro-optimization when your target audience have variety of devices with multiple types of hardware. Here different versions of virtual machines will running on different processors at different speeds. Moreover, emulator won't tell you much about the performance on particular device. There is a JIT: factor that influences the coding so the code that is best for with JIT: may not good for without JIT: so you should be careful for coding and create code that will prove efficient at all levels.

Android apps development is object oriented programming so creating object is essential, but creating unnecessary object is costly affair because object creation is not free. Each object consumes some memory so we have to allocate it and for temporary object with generational garbage collector with per-thread allocation is cheaper, but memory consumption is anyway costly so avoid it most possible ways.

You can save memory allocation many ways like if your method is running a string and it appended to a StringBuffer you have to change the signature so function will append directly and won't create short lived objects. Same the way if you are extracting strings from a set of input data you have to return a sub-string of original data, not a copy. One more best practice in Android application programming is that you have to slice up multidimensional arrays into single one-dimensional arrays.

Let me explain it further. If you have an array of Integrer objects that is diminish the performance so use an array of ints for better performance. If we want further improvement we should use two parallel arrays of ints than the array of (int,int) objects. When you need implementation of a container which is storing tuples of (Foo,Bar) objects you might have slow performance than that of two parallel Foo() and Bar() arrays of custom objects. This is not advisable only in case when you are designing an API for other code to access. In short, you have to avoid short-term temporary objects creation in your Android apps programming so you will have less-frequent garbage collection that directly leaves impacts on the performance hence on the user experiences.

There are many other tricks to improve the performance of you Android apps using efficient coding practices as a good and efficient Android programmer.
Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.