Another question, how to you folks map between you...
# server
l
Another question, how to you folks map between your data classes, and the different layers of your code? Are you doing it manually, with extension functions maybe, or using a library like shapeshift ?
👐 1
K 1
g
If you mean from a local database or network , I just use
.map
😅 1
d
Does Shapeshift do immutable migrations (ie. calling the target constructor reflectively? The presence of
vars
and default values in the target class would seem a little worrying to me because if you forget a mapping then you'll possibly end up with invalid data in the target,
a
I do it manually with
.toX
extension functions. I find that object mapping libraries are more trouble than they're worth. Even efficient ones that use code generation have issues like dealing with non-standard behavior or potentially obfuscating compiler errors.
☝️ 1
👍 10
s
Manual "data mappers" 😅
c
Manually as well.
m
I've been meaning to take a closer look at Shapeshift for some time now. What I found a bit confusing was that, at least in the README, the mapping annotations are on the source class. It's quite counterintuitive to me to give the source class knowledge about what target class(es) it is going to be mapped into and what those look like. So right now, manually mappers as well 😅
l
annotations aren't mandatory, you can also create an external mappers (as they say, kotlin developers don't like the magic of annotations 😄 )