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)
Many computer systems rely on retrieving data from a data store and displaying for the user. User changes data and the data is updated to the store Key flow: Data store and User Interface Temptation/But Natural: Tie the Data store and User Interface Problem: 1.The user interface changes more than data store 2.Mixing business logic and presentation The Purpose
User interface logic tends to change more frequently than business logic, especially in Web-based applications.  User interface code tends to be more device-dependent than business logic Application may display the  same  data in different ways.  Separate development effort.  Other consequences
How do I separate Presentation ,Logic and Data for a near-perfect, reliable and future-proof solution? QUESTION…
M odel,  V iew,  C ontroller   Model-View-Controller  is a fundamental design pattern for the separation of user interface presentation from business logic and data. SOLUTION…
Software Architecture(Engineering) Object Oriented Orderly Code Reuse What MVC Is…
MVC Is 31 Years Old! Smalltalk-80 (circa 1980)  MVC first discussed in 1979 by  Trygve Reenskaug MFC (Document/View) Java’s Swing Apple’s Cocoa (Core Data) MVC is suited for GUI(Graphical User Interface) Development! History
More than 10 GUI frameworks (enterprise) More than 15 web-based  frameworks Implement MVC(web). Made popular by Ruby on Rails Developing applications for iphone and Android phones use the MVC(more tight coupling) design pattern MVC where…Almost Anywhere
Data Storage/Access Often Data source backed MySQL, MSSQL, Web Service, it doesn’t matter… 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). Simply, they represent the data your application manages MODEL
HTML Templates: All formatting(css,js,jq etc) related code belongs here. The view manages the display of information. VIEW
Be concern… Process user inputs, communicate with Models and Views Acts Like a Betweener  Much of the application’s core logic Invoke model, assign values to views The controller interprets the mouse and keyboard  inputs from the user, informing the model and/or the view to change as appropriate. CONTROLLER
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
The Model does not depend on view nor the controller but the controller and view depend on model. Only the model has access to the database Only Controller can request the Model to change state.(the view may ask about It’s state). MVC due to it’s popularity this points have been misrepresented;but the order it tries to bring should be the engineers focus. Must be Clear….
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? With MVC you can do a design for one app and implement over several different  platforms easily. For example the application which was developed at the AVNLab for iphone, and android.It is a clear demo of MVC for mobile. 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 ;). Do you know…..
We have  seen that with MVC: Good architectural design Code is organized and structured  Easy code maintenance   Because of abstraction, better strategic positioning of code will minimize the hunt for places to change Easy to extend and grow Modify parent classes, drop in new controller, etc. Ease  of Testing  Model  can be tested separately from the user interface. Why MVC?
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.  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. 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. 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.
Implementing Model View Controller in Kohanaphp. Simple Information collection form: Demo of MVC for Barcampcameroon 2010: http://njielitumbe.livejournal.com Implementing Model view Controller in ASP.NET         http://msdn.microsoft.com/en-us/library/ff647462.aspx * Implementing Model View Controller for iphone and Android with Jqtouch(written by mambenanje at AfroVisioNgroup lab in about 3 hours) -  http://www.packtpub.com/article/build-iphone-android-ipad-applications-jqtouch-jquery EXAMPLE CODE
http://msdn.microsoft.com/en-us/library/ff649643.aspx With 6,203,493 and still counting, Google is your Friend   :  http://www.google.com/search?hl=en&q=mvc Afrovisiongroup:www.afrovisiongroup.com Wikipedia: http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller   REFERENCES
THANK YOU  

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

  • 1.
    Web, Enterprise andMobile: 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.
    Many computer systemsrely on retrieving data from a data store and displaying for the user. User changes data and the data is updated to the store Key flow: Data store and User Interface Temptation/But Natural: Tie the Data store and User Interface Problem: 1.The user interface changes more than data store 2.Mixing business logic and presentation The Purpose
  • 3.
    User interface logictends to change more frequently than business logic, especially in Web-based applications. User interface code tends to be more device-dependent than business logic Application may display the same data in different ways. Separate development effort. Other consequences
  • 4.
    How do Iseparate Presentation ,Logic and Data for a near-perfect, reliable and future-proof solution? QUESTION…
  • 5.
    M odel, V iew, C ontroller Model-View-Controller is a fundamental design pattern for the separation of user interface presentation from business logic and data. SOLUTION…
  • 6.
    Software Architecture(Engineering) ObjectOriented Orderly Code Reuse What MVC Is…
  • 7.
    MVC Is 31Years Old! Smalltalk-80 (circa 1980) MVC first discussed in 1979 by Trygve Reenskaug MFC (Document/View) Java’s Swing Apple’s Cocoa (Core Data) MVC is suited for GUI(Graphical User Interface) Development! History
  • 8.
    More than 10GUI frameworks (enterprise) More than 15 web-based frameworks Implement MVC(web). Made popular by Ruby on Rails Developing applications for iphone and Android phones use the MVC(more tight coupling) design pattern MVC where…Almost Anywhere
  • 9.
    Data Storage/Access OftenData source backed MySQL, MSSQL, Web Service, it doesn’t matter… 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). Simply, they represent the data your application manages MODEL
  • 10.
    HTML Templates: Allformatting(css,js,jq etc) related code belongs here. The view manages the display of information. VIEW
  • 11.
    Be concern… Processuser inputs, communicate with Models and Views Acts Like a Betweener Much of the application’s core logic Invoke model, assign values to views The controller interprets the mouse and keyboard inputs from the user, informing the model and/or the view to change as appropriate. CONTROLLER
  • 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.
    The Model doesnot depend on view nor the controller but the controller and view depend on model. Only the model has access to the database Only Controller can request the Model to change state.(the view may ask about It’s state). MVC due to it’s popularity this points have been misrepresented;but the order it tries to bring should be the engineers focus. Must be Clear….
  • 14.
    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? With MVC you can do a design for one app and implement over several different platforms easily. For example the application which was developed at the AVNLab for iphone, and android.It is a clear demo of MVC for mobile. 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 ;). Do you know…..
  • 15.
    We have seen that with MVC: Good architectural design Code is organized and structured Easy code maintenance Because of abstraction, better strategic positioning of code will minimize the hunt for places to change Easy to extend and grow Modify parent classes, drop in new controller, etc. Ease of Testing Model can be tested separately from the user interface. Why MVC?
  • 16.
    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. 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. 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. 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.
  • 17.
    Implementing Model ViewController in Kohanaphp. Simple Information collection form: Demo of MVC for Barcampcameroon 2010: http://njielitumbe.livejournal.com Implementing Model view Controller in ASP.NET http://msdn.microsoft.com/en-us/library/ff647462.aspx * Implementing Model View Controller for iphone and Android with Jqtouch(written by mambenanje at AfroVisioNgroup lab in about 3 hours) - http://www.packtpub.com/article/build-iphone-android-ipad-applications-jqtouch-jquery EXAMPLE CODE
  • 18.
    http://msdn.microsoft.com/en-us/library/ff649643.aspx With 6,203,493and still counting, Google is your Friend  : http://www.google.com/search?hl=en&q=mvc Afrovisiongroup:www.afrovisiongroup.com Wikipedia: http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller REFERENCES
  • 19.

Editor's Notes

  • #4 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.
  • #6 Wikipedia: “ In software engineering, a design pattern is a general reusable solution to a commonly occurring problem in software design”
  • #10 Wikipedia: ” The domain-specific representation of the information that the application operates.”
  • #11 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.”
  • #12 Wikipedia: “ Processes and responds to events, typically user actions, and may invoke changes on the model.”
  • #18 *The Model:( "http://search.twitter.com/search.json?q=".$_GET['q']); Twitter rest API), The View : the index.html and The Controller is the twigle.php. *Test here: http://www.afrovisiongroup.com/twigle