MVC(Model View Controller),Web,Enterprise,Mobile


Published on

MVC(Model View Controller) How it Can Ease development accross platforms.

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

No notes for slide
  • For example, new user interface pages may be added. If presentation code and business logic are combined in a single object, you have to modify an object containing business logic every time you change the user interface. This is likely to introduce errors and require the retesting of all business logic after every small user interface change. . Migrating from a browser-based application to support personal digital assistants (PDAs) or Web-enabled cell phones, you must replace much of the user interface code, whereas the business logic may be unaffected. For example, a developer may prefers a spreadsheet view of data whereas ,management prefers a pie chart of the same data. In some rich-client user interfaces, multiple views of the same data are shown at the same time. Designing visually appealing and efficient HTML pages generally requires a different skill set than does developing complex business logic. Rarely does a person have both skill sets. Therefore, it is desirable to separate the development effort of these two parts.
  • Wikipedia: “ In software engineering, a design pattern is a general reusable solution to a commonly occurring problem in software design”
  • Wikipedia: ” The domain-specific representation of the information that the application operates.”
  • Wikipedia: “ Renders the model into a form suitable for interaction, typically a user interface element. Multiple views can exist for a single model for different purposes.”
  • Wikipedia: “ Processes and responds to events, typically user actions, and may invoke changes on the model.”
  • *The Model:( "".$_GET['q']); Twitter rest API), The View : the index.html and The Controller is the twigle.php. *Test here:
  • MVC(Model View Controller),Web,Enterprise,Mobile

    1. 1. Web, Enterprise and Mobile: Seen in Kohana php, .Net, iphone, and Android development. For BarCamp Cameroon 2010 by Njie-Litumbe.L.Nara Developer, AfroVisioN Group MVC(Model View Controller)
    2. 2. <ul><li>Many computer systems rely on retrieving data from a data store and displaying for the user. </li></ul><ul><li>User changes data and the data is updated to the store </li></ul><ul><li>Key flow: Data store and User Interface </li></ul><ul><li>Temptation/But Natural: Tie the Data store and User Interface </li></ul><ul><li>Problem: </li></ul><ul><li>1.The user interface changes more than data store </li></ul><ul><li>2.Mixing business logic and presentation </li></ul>The Purpose
    3. 3. <ul><li>User interface logic tends to change more frequently than business logic, especially in Web-based applications. </li></ul><ul><li>User interface code tends to be more device-dependent than business logic </li></ul><ul><li>Application may display the same data in different ways. </li></ul><ul><li>Separate development effort. </li></ul>Other consequences
    4. 4. <ul><li>How do I separate Presentation ,Logic and Data for a near-perfect, reliable and future-proof solution? </li></ul>QUESTION…
    5. 5. <ul><li>M odel, V iew, C ontroller </li></ul><ul><li>Model-View-Controller is a fundamental design pattern for the separation of user interface presentation from business logic and data. </li></ul>SOLUTION…
    6. 6. <ul><li>Software Architecture(Engineering) </li></ul><ul><li>Object Oriented </li></ul><ul><li>Orderly </li></ul><ul><li>Code Reuse </li></ul>What MVC Is…
    7. 7. <ul><li>MVC Is 31 Years Old! </li></ul><ul><li>Smalltalk-80 (circa 1980) </li></ul><ul><li>MVC first discussed in 1979 by Trygve Reenskaug </li></ul><ul><li>MFC (Document/View) </li></ul><ul><li>Java’s Swing </li></ul><ul><li>Apple’s Cocoa (Core Data) </li></ul><ul><li>MVC is suited for GUI(Graphical User Interface) Development! </li></ul>History
    8. 8. <ul><li>More than 10 GUI frameworks (enterprise) </li></ul><ul><li>More than 15 web-based frameworks Implement MVC(web). </li></ul><ul><ul><li>Made popular by Ruby on Rails </li></ul></ul><ul><li>Developing applications for iphone and Android phones use the MVC(more tight coupling) design pattern </li></ul>MVC where…Almost Anywhere
    9. 9. <ul><li>Data Storage/Access </li></ul><ul><li>Often Data source backed </li></ul><ul><li>MySQL, MSSQL, Web Service, it doesn’t matter… </li></ul><ul><li>Manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller). </li></ul><ul><li>Simply, they represent the data your application manages </li></ul>MODEL
    10. 10. <ul><li>HTML Templates: </li></ul><ul><li>All formatting(css,js,jq etc) related code belongs here. </li></ul><ul><li>The view manages the display of information. </li></ul>VIEW
    11. 11. <ul><li>Be concern… </li></ul><ul><li>Process user inputs, communicate with Models and Views </li></ul><ul><li>Acts Like a Betweener </li></ul><ul><li>Much of the application’s core logic </li></ul><ul><li>Invoke model, assign values to views </li></ul><ul><li>The controller interprets the mouse and keyboard inputs from the user, informing the model and/or the view to change as appropriate. </li></ul>CONTROLLER
    12. 12. CONTROLLER -Input Filters(authentication…) -Action Dispatching -Output filters(Compression, cache…) MODEL Data Persistence -Relationships REQUEST RESPOND Database Only I know the DB VIEW -Presentation -Layout -Graphic Interface
    13. 13. <ul><li>The Model does not depend on view nor the controller but the controller and view depend on model. </li></ul><ul><li>Only the model has access to the database </li></ul><ul><li>Only Controller can request the Model to change state.(the view may ask about It’s state). </li></ul><ul><li>MVC due to it’s popularity this points have been misrepresented;but the order it tries to bring should be the engineers focus. </li></ul>Must be Clear….
    14. 14. <ul><li>With MVC It is easier to look for errors, by knowing the particular file(object) either it’s a View, Controller or Model than by knowing the line from which the error is coming from? </li></ul><ul><li>With MVC you can do a design for one app and implement over several different platforms easily. </li></ul><ul><li>For example the application which was developed at the AVNLab for iphone, and android.It is a clear demo of MVC for mobile. </li></ul><ul><li>With MVC design pattern don’t bother about your language expertise. You would find your self translating from one framework or one mobile phone development plateform to another rather than re-coding . As I moved from Code Igniter to Kohana ;). </li></ul>Do you know…..
    15. 15. <ul><li>We have seen that with MVC: </li></ul><ul><li>Good architectural design </li></ul><ul><li>Code is organized and structured </li></ul><ul><li>Easy code maintenance </li></ul><ul><li> Because of abstraction, better strategic positioning of code will minimize the hunt for places to change </li></ul><ul><li>Easy to extend and grow </li></ul><ul><li>Modify parent classes, drop in new controller, etc. </li></ul><ul><li>Ease of Testing </li></ul><ul><li>Model can be tested separately from the user interface. </li></ul>Why MVC?
    16. 16. <ul><li>Supports multiple views: Because the view is separated from the model and there is no direct dependency from the model to the view, the user interface can display multiple views of the same data at the same time. For example, multiple pages in a Web application may use the same model objects. </li></ul><ul><li>Accommodates change: User interface requirements tend to change more rapidly than business rules. Users may prefer different colors, fonts, screen layouts, and levels of support for new devices such as cell phones or PDAs. Because the model does not depend on the views, adding new types of views to the system generally does not affect the model. As a result, the scope of change is confined to the view. </li></ul><ul><li>Easier support for new types of clients: To support a new type of client, you simply write a view and controller for it and wire them into the existing enterprise model. </li></ul><ul><li>Development of the various components can progress in parallel: Once the interface between the components is clearly defined. The designer can be doing the interface while the developer does the logic; It is merged later. </li></ul>
    17. 17. <ul><li>Implementing Model View Controller in Kohanaphp. </li></ul><ul><li>Simple Information collection form: </li></ul><ul><li>Demo of MVC for Barcampcameroon 2010: </li></ul><ul><li>Implementing Model view Controller in ASP.NET </li></ul><ul><li> </li></ul><ul><li>* Implementing Model View Controller for iphone and Android with Jqtouch(written by mambenanje at AfroVisioNgroup lab in about 3 hours) </li></ul><ul><li>- </li></ul>EXAMPLE CODE
    18. 18. <ul><li> </li></ul><ul><li>With 6,203,493 and still counting, </li></ul><ul><li>Google is your Friend  : </li></ul><ul><li> </li></ul><ul><li>Wikipedia: </li></ul><ul><li> </li></ul>REFERENCES
    19. 19. <ul><li>THANK YOU  </li></ul>