1

In my application I have to consume data from an API, do some processing and then store the data retrieved from the API in my own database. Should I have multiple Data Mappers? One for the API and other for my database?

Thanks.

3

I tend to find it a good idea to use a mapping at each point of conversion, yes. While maybe a hair more work to start, it tends to keep things from having to be split later and nicely isolates functionality into the context areas that it really belongs. Who's to say that a year down the road your external API source won't change? Easier at the outset I think to create the mappings separately than have to break a single global mapping into separate ones later.

Tools like AutoMapper (C#, others I'm not sure of offhand but I'm sure they exist) can make this a very painless process.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.