Search code examples
c#architectureobject-object-mapping

What is the objective of an ObjectMapper?


I don't understand why in Object Oriented development people are using some ObjectMapper class. Could you explain me what is the purpose of this kind of class? I'm also looking for documentation about it. I found a lot of information explaining how to create it but nothing about how and why to use it. Do you know where I can find a good article, blog on this (in C# if possible).

A sub-question to be sure to understand. Are ObjectMapper something used in C++?

Thank you.


Solution

  • Object to Object mapping is not a programming language related question.

    There are plenty of useful scenarios when Object to Object mapping comes in handy.

    One common scenario is when you have designed your business object model and developed your business services that deal with those objects, within your domain application layer. Now, what if you want to expose your data to any UI and/or clients? You obviously do not want to expose business objects. Here comes the mapping! You might transform your business objects to DTO’s if you’re dealing with web services. You might transform them to ViewModels if the consuming UI is an MVC application…

    Hope this helps!