The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Model view presenter

In my project, 2.0,i am implementing MVP pattern..what i am confused about is how to move data from view to presenter..example..
On a form,user has to give percentage,for which i am using textbox,now presenter can access this value through a property on IView(which returns string),but in domain model ,the class which has percentage property is,what happens now? Should,the presenter cast
the string into int,and then initialize the property of class(which takes int)? or what else could be done?

Another,issue..say my class TransportPackage is composed of Destination on form,user selects destination for a package using a combobox,again presenter gets the selected value as string(destination name) how to initialize the Destination object of TransportPackage?
Should,i search in collection of destination,which will return a destination object,and then assign this object to TransportPackage object..

Friday, July 14, 2006
RE: Question 1
IView should return Integer as opposed to String for percentage.

RE: Question 2, Two Options,

Option 1:
Presenter converts from String to Destination object.

Option 2:
Destination Domain Object implements "TryParse" and "Parse" methods as in Int32.TryParse and Parse, which esstentially parses String to obtain object.

For 9 out of 10 times, I go with option 2 as it keeps all conversion code in the same place as the domain object.

Here is a recent articles on MVP,

Saturday, July 15, 2006
yu say view should return int for percentage..but i am going with string only..and parse it in presenter..and assign to domain object...

yur second option seems a good option..
Sunday, July 16, 2006
Option 1:
Presenter converts from String to Destination object.

can yu give an example of how to do it?

Because,to convert it into Destination object it seems,i need to get destinationcollection,match string and get that object..
Monday, July 17, 2006
In a nutshell,

Destination userPercentage = new Destination( Textbox.value )

The problem with code like this is that there are a LOT of ways to do this, and it really depends on what you're trying to do. Nobody ever told me I needed to use a DestinationCollection or try to find an existing object instead of creating a new one, so I didn't.
Monday, July 17, 2006
thks david
Tuesday, July 18, 2006

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz