Why I gave up with Realm

Why I gave up with Realm

Reading Time: 3 minutes

I remember that once I felt with the world at my feet. I felt able to do everything. I was using Realm as local database for my Android site project apps. And I felt like that all the people who don’t use it were really wrong. But it was just a bubble. Nice but fragile. And after a lot of headaches the bubble bursted.

Disclaimer: In this post I don’t want to give the feeling that I don’t like Realm or that it isn’t a good database. I will just tell you in a few lines my experience and why, after more than a year using it I gave up and started to use another local database for my projects. I’m probably more guilty of the headaches than Realm

I was happy thinking that Realm was the best option for a mobile database. Everybody talked really good about it (yes, of course it wasn’t everybody, but it felt like it was), there was a lot of information online (overall in Stackoverflow), the documentation was really complete and it was created in a different way. It uses native code so it promised to be really fast (and probably it is). But yeah, it comes with a high price. And I don’t mean that it cost money. It’s great that it’s completely free. But the cost of time. All the problems I had with it. All the code needed. All the headache I had. In this sense, yeah, it’s a bit expensive.

Let me explain you three things that made me be in love with Realm and three things that made me change to SugarORM.

Good things

1.- Fast: I never really checked if it is true. I just looked some graphics, saw that it is made using native code and I went with it. At the beginning I just wanted to try, but the speed was so good so I stayed with that.

2.-Cool: When I adopted this database in my private projects, it was the new in the hood and that’s always cool. People talked wonderfully about Realm, all the comparison charts I saw had Real as clear winner. It was not difficult to try a bit of this and feel part of this coolness wave.

3.-Relations: With Realm is really easy to create a models. Before I tried other databases that were a bit more complicate to create models with other models as variables, Realm offered me something as easy as use the object as a variable.

Bad things

1.- Stetho: It simply doesn’t work. Or at least I couldn’t make it work. There is a library I github to make it work but i think it’s a bit out of date and it doesn’t work with the last version of okhttp.

Stetho is a nice open source tool created by Facebook that allow to see what’s in the mobile database from the browser.

2.-Threads: It tooks me many time to domain without errors this facet of Realm but at the end it never stops to gave me problems. I don’t say that there is a problem I’m Realm. Probably the problems was me, but my patience had a limit.

3.-Boilerplate code: An effect of the last point. To be able to work with Realm in different threads you have to open an instance of the database, make what you need to do and close it before continue. With that in mind you can imagine how my repository class looked like. Every method that interacted with the mobile database had this two lines of code. Open and close instance. If I have 10 methods that interact with the database, 20 lines of code repeated all over the class.

As I said, Realm is now a part of my past. SugarORM has replaced it and I should say that, by the moment, I’m really happy with the change. It’s flexible, manage the relationships easy and it’s fast enough.

I will miss how Realm manage the Relationships, and maybe this read/write never checked high speed but at the end, don’t need to be looking for why something is failing accelerate my productivity and improve my mental health.

0

Leave a Reply

Your email address will not be published. Required fields are marked *