On Wed, Feb 17, 2010 at 2:12 PM, El Mentecato Mayor
<[email protected]> wrote:
> I currently don't use MVP, but more like MVC where the View and
> Controller are sometimes in the same class (when the views/controllers
> are rather trivial), but regarding the example that Supercobra gave,
> and to answer your question Yaakov:
>
> Another way of sending model information is using interfaces. For
> instance, if I knew that I would be displaying a speedometer for car
> and a bike (and maybe something else as well), I would have done
> something like:
>
> new SpeedoMeterView(Vehicle vehicle)...
>
> where Vehicle is an interface with methods that provide access to all
> properties that the SpeedometerView needs.  I do this a lot to with my
> views.  To me, this is a lot better in terms of maintainability,
> readability and productivity, than just using primitives, especially
> when you have complex models.

Right. That's why I hinted "easily", i.e.,  that passing real models
into the View makes the View not be **easily** reusable. I.e., you
need to create other structures that unify your models. In the example
of the speedometer, it's probably even better to have it do:
speedometer.setData(HasSpeed something)

where 'HasSpeed' is an interface that all your relevant models would
have to implement. So, it IS doable, but introduces a bit of a
side-affect to your model which is not necessarily that great of an
idea because in a lot of cases, implementing HasSpeed interface for a
Car class is meaningless everywhere except your View. That's not good
as you are introducing **implicit** dependencies of your Model to the
View. In other words, you are starting to code your model, which has
nothing to do with the View per se, to the one particular tier - the
presentation tier. I don't think that's a good thing.

Yaakov.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to