Well Google I/O 17 came out with a few interesting things on Android. One of them was the long coming was room persistence. Well persistence has been in Java quite some time and it was high time it had to come to Android ecosystem. This write up is my take on the persistence library.
Well I have seen developers still write CRUD helpers for sqlite in android
- Screams of languish *
Well the origins of the DAO,DTO and Entity pattern has been from the Mircosoft era of 1992(called as jet DAO/DTO) which is mostly used in state-less based architecture (HTTP) service has had a lot of advantages/disadvantages over a period of time. I feel using them ensures separation between parts of an application. And it is right to get it into android ecosystem because the entire approach of using databases in android was spaghetti all over. With the usage of “room” things will become much cleaner on the design pattern perspective.
I found DAO’s in the goto docs which represents params in the query like this
From my experience of backend there is another simple representational way of writing the same DAO. But I am not sure if this is accepted in the @Query validation processor.
If there still exists business logic that evaluates entity and maps them to DTO. I believe an extended Mapper with MapperFactory can be used to constuct this DTO. Well before finishing this blog about persistence on a positive note. Well there few drawbacks with this design pattern like leaky abstraction & abstraction inversion.
You can add room into your project with this
The sample project of how to use it is in this link. I am still exploring about other architecture components and will definitely talk about how all of these things play together.