Hi, Troy Gilbert wrote: > Brett, > > Events are actually an a pretty fundamental component of an MVC > implementation. Events are most often used by the model to notify the view > and/or controller of changes (Observer pattern).
Usually the model does not talk to the controller (see the diagram at the java blueprints url below). --------------------------------------------------------------------- Observer(page 94) - The MVC pattern often uses the observable pattern to manage communication. This is usually done for the following parts of the system: . between view and controller so that a change in the view triggers a response in the controller. . between model and view so the view is notified of changes to the model. [Stelting and Maassen(2002) "Applied Java Patterns", page 213] --------------------------------------------------------------------- > If your model is responding to *any* events then its really not acting as a > model in the traditional MVC sense. Models should be "pure" data, they > should basically represent state and contain no behavior. The exception, of > course, are structural behaviors like collection management > (ArrayCollection) or notification (Bindable). If you have parts of your > model that are listening for events that's a good indicator (in my book) > that your model needs some refactoring to truly be MVC. I tend to work > toward the goal of the model having only properties, no methods. The model should just be made up of objects which are modelled on the business processes and should adhear to the usual best practices. Properties represent state, methods implement behavior to modify state based on some business logic. Therefore, the model should define the state and business logic(behaviour) to manage the model's state. The ModelLocator(Cairngorm speak?) should not contain functional methods, because the ModelLocator is not the model, its just the locator of models. This is what the java blueprints has to say about the model in MVC. ------------------------------------------------------------------------ Model - The model represents enterprise data and the business rules that govern access to and updates of this data. Often the model serves as a software approximation to a real-world process, so simple real-world modeling techniques apply when defining the model. [ http://java.sun.com/blueprints/patterns/MVC-detailed.html ] ------------------------------------------------------------------------ Even though the pattern in this instance is being descibed for an "enterprise" application, the rules for the pattern dont change. > On 3/25/07, rumpleminzeflickr <[EMAIL PROTECTED]> wrote: > >> >> Hi there, >> >> I'm building a flex app using MVS and it seems to me events can break >> the MVC pattern? >> >> I.e a event in the ui layer could trigger something directly in the >> model etc.. >> >> Is it recommended to use Events in this way or am I being totally dumb >> here.? >> >> Any feedback appreciated.. >> >> Many thanks, >> >> Brett regards, shaun

