1. Keep Things Modular
Keep Objects and classes on tasks they were designed for. For instance, don’t try and perform network tasks in a Datastore class, and the like. The more you separate your logic, the easier it will be to update individual classes later. A good rule of thumb is to keep your method sizes less than 50 lines and your classes less than a few hundred lines.
2. Implement a Consistent Code Formatter
On Android Studio; you can set up your preferred format style under Preferences/Code Style/Java. You can export it and share it across your team once you have a custom template. Any team member can then apply it to a project, and your code will be automatically rearranged. This will save you hours of time and improve readability.
3. Test your code throughout your Android development project
Unit tests are a key part of implementing a test-driven development strategy (TDD). This is absolute necessary to ensure that your code performs the way you expect it to. There’s a minefield of useful information regarding unit testing on Google’s Android Developer site.
4. Add Automated Code Checking.
There are several tools out there to help you code and make sure that you are following the industry’s best practices. The most common ones are PMD, FindBugs, and Checkstyle. You could learn from GitHub repo of as to how to implement FindBugs, Checkstyle, and PMD checks in your app.
5. Go With an MVP Approach.
Using an MVP method in development means separating the Model, View, and Presenter in your code (not to be confused with ‘Minimum viable product’). This is similar to the MVC pattern that’s talked about in iOS.
The fundamental idea is that the View layer should never contact the Model layer directly — because that’s what the Presenter is for. In dissecting the presentation layer from the logic, the way you layout the data on screen becomes modularized and separated from how you pull the data from a server or a database. This style lends itself to easier testing, higher readability, and more seamless collaboration overall.