In Realm
, in order for an object to be able to be persisted it must either implement RealmModel
or extend RealmObject
. Are there benefits to using one over the other?
All it says in the realm docs is:
An alternative to extending the RealmObject base class is implementing the RealmModel interface and adding the @RealmClass annotation.
All methods available on RealmObject are then available through static methods.
Considering that extending any non-RealmObject
classes is not possible even if you're implementing RealmModel
and adding @RealmClass
, in my opinion you just get additional complexity by forcing yourself to use for example RealmObject.isValid(realmObject)
instead of realmObject.isValid()
that you get naturally for free using extends RealmObject
.
So no, you should stick to extending RealmObject
. Using implements RealmModel
gives you no additional benefit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With