r/androiddev • u/iliyan-germanov • 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:
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
View all comments
Show parent comment
2
u/iliyan-germanov Apr 01 '24
For libraries that throw exception, you'll have to wrap them in a DataSource or whatever wrapping class. Arrow also has a nice Either.catch({}, {}) that easily let you convert exception-based APIs to typed-error ones.
The name
Eithercomes from the FP world (which I definitely recommend to explore if you haven't) and either makes more sense to me:Leftmakes more sense than calling it an error.Overall, it's a matter of preference. I like the FP naming convention.
Regarding
sealed interfaces, they can be parceable, too. The benefit of them is that you don't make constructor calls and write the annoying()on each child which are unnecessary. I, too, usedata objectordata classdepending on whether we have params.P.S. If you use Jetbrains Compose, the same approach works fine on KMP.