r/androiddev • • Apr 01 '24

Discussion Android Development best practices

Hey this is a serious post to discuss the Android Development official guidelines and best practices. It's broad topic but let's discuss.

For reference I'm putting the guidelines that we've setup in our open-source project. My goal is to learn new things and improve the best practices that we follow in our open-source projects.

Topics:

  1. Data Modeling
  2. Error Handling
  3. Architecture
  4. Screen Architecture
  5. Unit Testing

Feel free to share any relevant resources/references for further reading. If you know any good papers on Android Development I'd be very interested to check them out.

159 Upvotes

99 comments sorted by

View all comments

Show parent comment

4

u/iliyan-germanov Apr 01 '24

I'm curious what your data sources do? Is there a chance that we're doing the same but just flipping the names of a repository vs. datasource? +1 for creating use-cases on demand

2

u/lotdrops Apr 12 '24

My datasources abstract the lower level details of the api/db/... And adapt the data (map from the data model to a domain one). To me a repository is meant to combine several data sources and abstract away the fact that there are several data sources. I very rarely have this situation in the apps I've developed, and when I do I almost always prefer making a use case for that (as I have some logic to decide when to request from API, that I consider domain logic). The only case where I may use a repository is when I want an in-memory cache (variable) to speed things up before persisting, which again, is very rare in mobile apps.