Assuming I have the following class:
data class Email(val id:String,
val from:String,
val to:String,
val cc: List<String> =listOf(),
val bcc: List<String> = listOf(),
val title: String?="",
val message:String?="",
val evaluation:Int?=0)
I have this data in different formats, json, txt, csv etc.
I want to make an importer for each format. The first option would be to add as many companion objects as data formats. The problem is that the API of the class will be cluttered with unnecessary details especially if the importers will do some pre-processing things before finally returning email objects.
In other word I want to separate the business logic from the representation.
Do I really need to do it? I came from other languages and best practices may change from one language to another.
If so, what is the best way to do it. I would like a link to some implementations in well-known libraries.
Thanks.