Jean-Paul S. Boodhoo

Sponsors

The Lounge

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Screen Bound DTO Update (Getting the terminology right)

I am going to be posting a small sample that demonstrates what I was talking about in my post describing using Screen Bound DTO’s Presentation Model.

In chatting with a couple of people, they correctly fixed my terminology to use lingo that most people have already got a cursory knowledge of. So with that said, the technique that I described with regards to objects that are designed specific to the screens that they are servicing is the concept of a Presentation Model. DTO’s are still in the picture with respect to the messaging that can occur between presenter and service (and vice versa). The presentation model is their to satisfy the needs of the UI, be if for databinding or other UI needs (such as coloring for rows in a grid, highlighting customers with bad credit etc).

Ok, now we are all on the same page.

 


Posted 09-28-2007 2:11 PM by bitwisejp
Filed under: ,

[Advertisement]

Comments

David Mc. wrote re: Screen Bound DTO Update (Getting the terminology right)
on 09-28-2007 6:27 PM

Oh, I am so looking forward to seeing this sample!  I read Fowler's definition of this awhile back, but hadn't seen a good .NET WinForms implementation of this...  

I've been struggling with things that create spaghetti code in the normal .NET application:  changing a value in one combobox cascades to update another combobox, fields that need to be enabled/disabled based on the values in other fields.  Maybe your sample can provide some guidance for these types of situations?

Thanks!

David Mc.

Jeremy D. Miller wrote re: Screen Bound DTO Update (Getting the terminology right)
on 09-29-2007 12:09 PM

A bit more on Presentation Model for WinForms:

codebetter.com/.../build-your-own-cab-part-5-the-presentation-model.

Microsoft is de facto pushing for a Presentation Model approach with Acropolis and WPF, but they call it something different.

Liam McLennan wrote re: Screen Bound DTO Update (Getting the terminology right)
on 09-29-2007 7:57 PM

I think this is a very interesting idea, but two things trouble me. Firstly, isn't this a violation of the DRY principle? Secondly, is there a nice way to handle the mapping between the domain model and the presentation model?

joeyDotNet wrote RE: Presentation Model Question
on 09-29-2007 9:03 PM

RE: Presentation Model Question

Jean-Paul S. Boodhoo wrote re: Screen Bound DTO Update (Getting the terminology right)
on 09-30-2007 1:34 PM

@Liam,

This is definitely not violating dry as the two models exist to serve different purposes. The presentation model is often much less complex and hierarchical than a rich domain model. The presentation is there to serve the needs of the UI, and the UI only. The domain model encapsulates business rules and rich associations/interactions with other objects in the domain model.

As far as   mapping is concerned. There are several ways that you can handle the mapping between domain/dto and presentation. Driving out the presentation model pieces in a test first manner could allow for you to drive out mappers in a test driven fashion at the time you actually need to perform the mapping from domain/dto to presentation. If you start to see duplication between mappers you can move to a metadata based mapper that leverages reflection to map from one object/set of objects to an object in the presentation model.