Whether a startup or an established large enterprise, every single entity needs to scale up their apps, to cope with an increasing number of users. Scaling leads to growth, which in turn leads to an increase in revenue. It is vitally important to scale up the Android development practices so that your clients can take the maximum benefits out of the apps you create for them. This is also very important to avoid any bugs, errors, or inconsistencies if there is a sudden increase in app usage. There are no specific strategies defined to get your Android application development practices to increase the number of users. However, there are certain simple tips you can follow, in order to bring an overall consistency, and help your apps scale up to a great extent, dealing with the app usage numbers game. #1. Follow a ‘modular’ approach and separate out the responsibilities Specific tasks need specific classes or objects. Try to avoid making use of the same objects, or classes, for performing different tasks. Every task should have a unique object or a class, limited to that task only. As an example, do not make use of datastore class for performing network-based tasks. The more you have logic separated, and confined within limits, the easier it would be to update later. If your classes and objects are shared by multiple job duties, then it will be extremely difficult to change things, when it is time to extend the capacity. An ideal thumb rule is to keep your classes limited to 100 lines, and methods to 50 lines. Exceeding them will not just make things complex, but also bring about a hell of a lot of restrictions when it is time for modifications. #2. Allow a consistent ‘formatting’ style all across your code Android Studio allows developers to have a preferred formatting style being set up by going to Preferences/Code Style/Java. As soon as you have a custom template in place, it is time now to export it to all your team members. Ensure that all team members apply that same custom template. When applied by individual team members, it automatically rearranges the code, making the code equally readable, across modules. Imagine, hours of time getting saved, due to an easy readability. This will also help in turn to bring about a coding consistency, whenever developers have to tackle modules of each other. In addition, the code review process gets a lot simpler, making it easier to analyze the differences. #3. Test the code as you ‘progress’ rather than doing it altogether Unit testing is critically essential to keep track of where your coding units are heading towards. Testing a small modular part individually is way easier than testing all the modules together after completion. As an example, assume a method by the name “StoreValue()”, within the DataStore class. Now it is ideal to perform unit testing on “StoreValue()” to check the data range and validate the same, instead of checking all the methods together within the entire DataStore, class, making it very difficult to track and solve the problem. #4. It is best to implement ‘automated’ code checking When you surf on Google, you might come across tons of tools that will check your code automatically after certain time intervals. You need to bring these tools into implementation, so that your code is regularly checked, and freed of all errors. Some nice automated code checking tools we would personally recommend are, Checkstyle, PMD, and FindBugs. #5. Keep ‘M-V-P’ layers differentiated from one another Herein, M-V-P should not be confused with the “Minimum Viable Product (MVP)”. We are talking about keeping Model, View, and Presenter, separate from one another. Never let a view layer communicate with the model layer directly. It is the job of a presenter layer to act as a bridge between the two. By keeping things distinct, you are splitting the logic of fetching the data from the server, from the logic of data layout on home screen. When you have roles clearly defined between three layers, it brings in a seamless collaboration, smooth testing, and an intuitive readability. #6. Have your operations ‘off-load’ from foreground onto the background App responsiveness might get affected, resulting in errors, bugs, freezes, or hangs, if all your default operations run on the foreground threads. Henceforth, try to shift all of them to the background threads. To do this, shift all the long running tasks at the class level. Make use of the IntentService class or AsyncTask class, that will activate a worker thread, and shift tasks, as and when needed. #7. Avoid the display of ‘ANR’ dialog box Following the offloading process, as discussed above, you can save your users from seeing the “Application Not Responding (ANR)” dialog box, showing up every now and then. By implementing a DoInBackground() method, you can get your worker thread to initiate the shifting process, with the help of an AsyncTask class. Alternatively, you can have a HandlerThread, or a Thread Handler class of your own. However, do not forget to set the priority of such a thread to the background else the app is likely to slow down due to UI thread being the same as the default thread. #8. Use ‘separate’ threads to handle different queries Do not be in a hurry to display data. You can still use the CursorLoader objects to quicken things up. This will prevent an activity to interact with the users while the background has still got some queries running. With the help of this object, there is a separate thread for background, initiated for every single Content Provider query, letting each one to return results, back to the same activity, once the query is called and processed. A few other ways to scale up coding Make use of StrictMode that will help you scan all the lengthy operations within the UI thread. Some special tools such as Traceview, Systrace, etc. helps you track app responsiveness bottlenecks. Load a progress bar in place, to keep users informed about the loading in progress. Due to a slower app loading setup, a splash screen installed can entertain users for a while. Images: ” Malaysia – December 8 , 2015: Hand holding white Samsung S6 Adge Smart Phone with S health App /Shutterstock.com“ ____________________________________________________________________________ Tweak Your Biz is a thought leader global publication and online business community. Today, it is part of the Small Biz Trends stable of websites and receives over 300,000 unique views per month. Would you like to write for us? An outstanding title can increase tweets, Facebook Likes, and visitor traffic by 50% or more. Generate great titles for your articles and blog posts with the Tweak Your Biz Title Generator.