Hey, how do you make proper distribution of your d...
# android-architecture
c
Hey, how do you make proper distribution of your data layer objects and why wouldn't you do something like this (code in the thread)
Copy code
sealed interface IExercise {
    val id: Int
}

sealed class Exercise {
    @Serializable
    data class Remote(
        override val id: Int,
    ) : IExercise {
        fun toCacheEntity() = DB(
            id = id,
        )
    }

    data class Model(
        val isFavorite: Boolean,
        override val id: Int,
    ) : IExercise {
        fun toRemote() = Remote(
            id = id,
        )
    }
    data class DB(
        override val id: Int,
    ) : IExercise, RealmObject() {
        fun toModel(isFavorite: Boolean = false) = Model(
            id = id, isFavorite = isFavorite,
        )
    }
}
Well, realm doesn't support nested classes and this wont work but I'm still curious if someone is doing something that will not end with 3 different folders with their individual classes and methods where I could use a more intelligent syntax
u
Whats the reason for the sealed class? Feels like wrong axis to me test
c
Excuse me for that, that is totally wrong. But even without that Realm doesn't allow its data classes to be inner classes
And for some reason I can edit this on my mobile device. The F.
Ok, you can't edit messages in this channel
u
i can
c
:| I'm being repressed 😂
Anyway it wouldn't work even without the sealed tag. But I wish I could have something like this. I'm already using this for my regular objects