简体   繁体   中英

Flex - implementing a MVC pattern without a framework, should httpservice be in the model or the controller?

I would like to implement the MVC pattern to an existing Flex project. I want to separate out the controllers and models from the views. They currently all live together in large mxml files.

My question is, should httpservice requests be in the model or the controller? What sort of advantages/disadvantages would there be to either?

I normally try to abstract any service request into a Command call (execute, result, fault) which gets the service it needs to called injected in (which can be a good idea to abstract even more and be a service delegate).

There's a good example of how to use short lives command objects in Parsley 's dev manual (one of the more popular frameworks).

I looked at httpservice , and it seems to me that, while the service itself might reside in a repository or Service Layer (between the controller and the model), using the service involves references to UI elements such as DataGrid . So the implementation of that service probably would occur in the controller, or even in a ViewModel object.

I would rather approach the services as something totally different - an MVCS, not just MVC. You should check the Introduction to Flex Application's Architecture I wrote in my blog.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM