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?
Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up.Sign up to join this community
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.