KConMapper — How To Automate Mapping Function Creation With Kotlin’s KSP

A KSP plugin that will help you get rid of writing boilerplate code for mapping from one object to another

Yanneck Reiß
Tech Takeaways

--

KConMapper library logo

Regardless if you are creating mobile applications or are working on a backend project using Kotlin. Creating functions in our applications that are responsible for mapping one object to another is a daily task you will come across.

This task mainly arises from the approach of object-oriented programming and common architecture approaches like Domain-driven design (DDD) or Clean Architecture, in which we create software models of entities from our project’s business or problem domain. Depending on the size of our project, we often define multiple layers within our selected architecture that will contain not one but multiple representations of an entity.

A common variation is that you find a domain object, a data access object (DAO), and multiple variations of a data transfer object (DTO) that all describe the same initial business entity.

These representations are often almost identical and differ, if at all, only in a few properties. Take the following code snippet as an example:

// Database representation of a user
data class UserEntity(
val…

--

--

Yanneck Reiß
Tech Takeaways

Follow me on my journey as a professional mobile and fullstack developer