I am a pretty new Kotlin dev, but I have done 20+ ...
# announcements
j
I am a pretty new Kotlin dev, but I have done 20+ years as a C# dev. In C# I have used a plugin called AutoMapper in some projects for mapping a domain model to an application model. What is the preferred way to do this in a big and complex Kotlin Android project? Is there a plugin that does this well or do you recommend some other approach?
a
Greetings @Jonas Frid, first of all, welcome to the Kotlin world! I don't know AutoMapper at all but if you are talking about mapping objects in your Data Access Layer (like an ORM) then we have Exposed which is pretty popular in the Kotlin world. Maybe you can check it out and see if it suits your needs or if I got your use case wrong then I apologize. https://github.com/JetBrains/Exposed
🙏 1
e
Hey @Jonas Frid, if you want object-to-object mapping you can use Dozer
1
j
What is the utility to have a domain model and a application model that are exactly the same?
I would use directly the domain model, and if the application model is different to the domain one, I would create manually a extension function to map it
5
👍 1
t
I’ve used Orika in the past. Not sure if it works with Android, but this might be a good comparison of jvm mappers: https://www.baeldung.com/java-performance-mapping-frameworks
👍 1
b
I think MapStruct fits your requirement. But I have no clue to what extent MapStruct is compatible with Kotlin. That being said MapStruct does feel very Java-ish
👍 1
j
@Javier sometimes in complex solutions like ours that use a lot of predefined API endpoints and a domain model decided by the API team, that domain model does not fit well with the mobile apps architecture. In that case you can really benefit from keeping the app model and domain model apart. Of course you can write code to map between them, but tools like AutoMapper in the C# world lets you define the differences. That can save a lot of time.
The thing I wanted to explore is object to object mapping…