Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Decouple or Strong Type?  (Read 7095 times)
myIP
Jr. Member
**
Posts: 11


View Profile Email
« on: April 13, 2009, 05:04:03 »

Should a controller be decoupled from a model, by using primitive types or should the parameters that are passed to the model should be received strong typed? 

If I recall correctly, I read that the model, view and controller, should be decoupled as much as possible for that they may be used for another application.  So when an event gets passed into a controller, it will extract the  data from the event and break it apart to its primitive type to be passed to the model.   Is this correct?  Or should the model receive the parameters from the controller strong typed?   Or is this correct?

Thanks.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: April 14, 2009, 05:39:41 »

The Value Object pattern is intended for passing stongly typed data across the tiers of an application. See the EmployeeAdmin demo in whatever language you prefer) for an example of this.

The primary decoupling we want to achieve is to supress model dependencies on the View. Your View has one mission in life: allow the user to interact with the domain model data. So it is understandable that there will be some level of dependencie on Model entities (ie VOs, Enums and other data carriers). However, by avoiding any coupling to the business actors in the view components, we can still see broader reusability in those components.

If you ever want to repackage a view component that relies on a Value Object, it is a relatively simple packaging refactor to put the reusable components and the value objects they depend on into a separate library.

Imagine you're doing a very specialized mapping application, and it uses a lot of corporate domain data. But you realize that the map view component you've built and the VO that carries coordinates, an image url, and some other common map-specific info could be reused, even sold as a separate component. The VO that feeds it is tangential to your corporate domain model, so you package the two in a mapping library and use the library in your app.

The proxies (model tier) of your app work with your corporate data, but also create these map VOs to associate it with the map locations and feed the view with it. 

So you've avoided coupling the view component to your proxies, commands or mediators, and thus they can be reused. Your proxies still know nothing about the app they're feeding, only entity data balled up in a VO and tossed to the other tiers.

-=Cliff>
Logged
myIP
Jr. Member
**
Posts: 11


View Profile Email
« Reply #2 on: April 15, 2009, 02:48:39 »

Yeah, that makes sense.  You explained it very well.  Thanks again.
Logged
Pages: [1]
Print