Exposing business entities in UI via mappers

Topics: CAB & Smart Client Software Factory
Sep 9, 2006 at 12:40 PM
originally posted by: bil_simser

I'm having a bit of a problem with the documentation on creating a mapper. As the doc says, the mapper is for converting your business entity to something for the view. The example is an Attachment (which I conder a domain object) to be added to a list view.

In the example, the view has a method that accepts an Attachment which then calls the AttachmentMapper to translate it into a ListViewItem. The view then updates its UI control by adding list items to the list view control.

However this means that I'm exposing my business object to my UI, which creates a coupling between the UI and the business layer (at least from a deployment perspective). If I don't do it this way I have to have the presenter (which should know about domain objects) update the view but what is it going to update it with? Certainly not a ListViewItem which will make the presenter dependent on the System.Form namespace.

Without creating a intermediate object am I really bound to have the UI reference the business layer and is the documentation really a best practice for exposing business objects to the UI?