MVC

XCase is based on Model-View-Controller (MVC) architecture.
  • Model stores all the data managed by XCase and raises events when the data is changed (which can be done only through Controllers or loading data from a file)
  • View binds to Model's events and displays the current state in GUI. This binding is unilateral, View cannot directly access/change the model.
  • Controllers provide methods for changing the model, which can be used by view and GUI (when processing user input), but doesn't change the View directly.

Example - Rename a Class

  1. User clicks on the Rename context menu item of a Class, types in a new name and presses Enter
  2. View checks whether the new name is different from the old one. If it is, it replaces the new name with the old one (because the new name will be set here in a different way and we want to see if everything works OK)
  3. View calls the Controller with the rename request
  4. Controller creates a Rename command, initializes it with the Model class and executes it
  5. The Rename command sets the Name property of the Model class and stores the old name for Undo
  6. The Model class detects the change to its Name property and invokes the PropertyChanged event
  7. The View representation of this class receives an update via Binding and updates the text box containing the class name.

Last edited Dec 16, 2008 at 8:33 AM by Kuba, version 5

Comments

No comments yet.