MVC Pattern. Flex implementation of MVC


Published on

This presentation will guide you through the MVC Pattern and Flex implementation of MVC (Cairgorm and Mate Frameworks)

Published in: Business, Technology
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

MVC Pattern. Flex implementation of MVC

  1. 1. MVC Pattern Flex implementation of MVC Anton Krasnoshchok
  2. 2. Please t urn o ff your c ell p hones or set them to vibrate Thank y ou f or y our c ooperation
  3. 3. UI, business logic and data <ul><li>Business applications consist of user interface (UI), business logic, and data models. </li></ul><ul><li>When UI, business logic and data are collapsed into one object in rich users interface, it can lead to some of the following problems: </li></ul><ul><li>Difficult to use the data outside that object </li></ul><ul><li>Hard to change the UI, when UI and data are locked in the same object. </li></ul><ul><li>Hard to use multiple views of the same data. </li></ul><ul><li>Difficult to synchronize multiple view of the same data. </li></ul>
  4. 4. MVC pattern <ul><li>Model - View - Controller (MVC) is an architectural pattern used in software engineering. </li></ul><ul><li>The MVC pattern is most commonly used to create interfaces for software applications, and, as the name implies, consists of three elements: </li></ul><ul><li>Model: contains the application data and logic to manage the state of the application. </li></ul><ul><li>View: present the user interface. </li></ul><ul><li>Controller: Handles user inputs to change the state on the application. </li></ul>
  5. 5. Comparison 3 -Tier with MVC <ul><li>3 -Tier architecture </li></ul><ul><li>MVC architecture </li></ul>PL BL DAL Model View Controller <ul><li>View tells to controller handle user inputs </li></ul><ul><li>Controller changes model state </li></ul><ul><li>Model tells view to update itself </li></ul><ul><li>View reads state information from model and updates itself. </li></ul>
  6. 6. Cairngorm Framework
  7. 7. Cairngorm elements <ul><li>Model Locator : Stores all of your application’s Value Objects (data) and shared variables, in one place </li></ul><ul><li>View : One or more Flex components (button, panel, combo box, Tile, etc) bundled together as a named unit, bound to data in the Model Locator, and generating custom Cairngorm Events based on user interaction (clicks, rollovers, drag-n-drop etc.) </li></ul><ul><li>Front Controller : Receives Cairngorm Events and maps them to Cairngorm Commands. </li></ul><ul><li>Command : Handles business logic, calls Cairngorm Delegates and/or other Commands, and updates the Value Objects and variables stored in the Model Locator </li></ul><ul><li>Delegate : Created by a Command, they instantiate remote procedure calls (HTTP, Web Services, etc) and hand the results back to that Command. </li></ul><ul><li>Service : Defines the remote procedure calls (HTTP, Web Services, etc) to connect to remote data stores. </li></ul>
  8. 9. Mate Framework Mate framework it is a tag-based, event-driven Flex framework. Benefits Highly decoupled Your classes do not extend from Mate Business logic is independent of framework Can be tested & reused Business logic decoupled from events Business logic decoupled from services Events are normal Flash events Can be reused
  9. 10. Basic steps Typically, the basic steps to create a Mate project are: 1. Add the compiled framework code to your project (Mate.swc). 2. Create a file that will be the EventMap . 3. Include the event map in your main Application file. 4. Create a custom event. 5. Somewhere, dispatch that event. 6. Add EventHandlers in your event map that listen for the event type you dispatched. 7. Execute some actions inside the EventHandlers block (ie: call the server, store data, etc). 8. Repeat 4-7 for every event you need.
  10. 12. Summary The MVC pattern provides a clear framework for design. The separation of responsibilities among the model, view and controller elements allows easy substitution of elements without disruptions to the overall application. This lets us easily expand applications based on the MVC pattern to meet changing requirements.
  11. 13. Last page <ul><li>Any questions ? </li></ul>