Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It depends on your architecture. If you're all on the same tier, then you can go without the wrapper, though I'd probably pass an interface that View implements to Controller. Functionally, and from a coupling perspective, the interface approach and the wrapper approach are equivalent.</p> <p>However, if UI is on one tier and the controller is on another, then passing/serializing an entire View object might be awkward, or even inefficient. In cases like this, you might want to pass a DTO back and forth, which would be easier to serialize and probably more efficient.</p> <p>I tend to favor the DTO approach, since if your architecture scales up, all you need to do is serialize and de-serialize. </p> <p>Also, if your View is complicated and has lots of pieces of data to pass back and forth with the Controller, you might start fighting the Long Parameter List smell with <a href="http://www.refactoring.com/catalog/introduceParameterObject.html" rel="nofollow noreferrer">Introduce Parameter Object</a> anyway, which is essentially a DTO.</p> <p>One more thing for you to chew on: for a complicated View, Controller will end up needing to map lots of pieces of data to various text boxes and other UI controls in the View. The same thing in reverse: View ends up grabbing data from a lot of controls and passing them to various methods in your Controller. </p> <p>I like separating these two. I give Views a DTO and I consider it the View's job to know where to "plug in" and "plug out" each piece of data. Both View and Controller are now coupled only to the DTO, as far as data is concerned anyway.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload