mvc(model view controller),web,enterprise,mobile

19
MVC(Model View Controller) 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

Upload: naral

Post on 07-May-2015

5.595 views

Category:

Education


0 download

DESCRIPTION

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

TRANSCRIPT

Page 1: MVC(Model View Controller),Web,Enterprise,Mobile

MVC(Model View Controller)

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

Page 2: MVC(Model View Controller),Web,Enterprise,Mobile

The Purpose

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 storeKey flow: Data store and User InterfaceTemptation/But Natural: Tie the Data store and User

Interface Problem:

1.The user interface changes more than data store2.Mixing business logic and presentation

Page 3: MVC(Model View Controller),Web,Enterprise,Mobile

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

Page 4: MVC(Model View Controller),Web,Enterprise,Mobile

How do I separate Presentation ,Logic and Data for a near-perfect, reliable and future-proof solution?

QUESTION…

Page 5: MVC(Model View Controller),Web,Enterprise,Mobile

Model, View, Controller

Model-View-Controller is a fundamental design pattern for the separation of user interface presentation from business logic and data.

SOLUTION…

Page 6: MVC(Model View Controller),Web,Enterprise,Mobile

Software Architecture(Engineering)Object OrientedOrderly Code Reuse

What MVC Is…

Page 7: MVC(Model View Controller),Web,Enterprise,Mobile

MVC Is 31 Years Old!Smalltalk-80 (circa 1980) MVC first discussed in 1979 by Trygve

ReenskaugMFC (Document/View)Java’s SwingApple’s Cocoa (Core Data)* MVC is suited for GUI(Graphical User

Interface) Development!

History

Page 8: MVC(Model View Controller),Web,Enterprise,Mobile

MVC where…Almost Anywhere

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

Page 9: MVC(Model View Controller),Web,Enterprise,Mobile

MODELData 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

Page 10: MVC(Model View Controller),Web,Enterprise,Mobile

HTML Templates: All formatting(css,js,jq etc) related code belongs

here.The view manages the display of information.

VIEW

Page 11: MVC(Model View Controller),Web,Enterprise,Mobile

* 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

Page 12: MVC(Model View Controller),Web,Enterprise,Mobile

CONTROLLER-Input Filters(authentication…)

-Action Dispatching-Output filters(Compression, cache…)

MODELData Persistence

-Relationships

VIEW-Presentation

-Layout-Graphic Interface

REQUESTREQUESTRESPONDRESPOND

DatabaseDatabase

Only I know the DBOnly I know the DB

Page 13: MVC(Model View Controller),Web,Enterprise,Mobile

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 databaseOnly 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….

Page 14: MVC(Model View Controller),Web,Enterprise,Mobile

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…..

Page 15: MVC(Model View Controller),Web,Enterprise,Mobile

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?

Page 16: MVC(Model View Controller),Web,Enterprise,Mobile

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.

Page 17: MVC(Model View Controller),Web,Enterprise,Mobile

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

Page 18: MVC(Model View Controller),Web,Enterprise,Mobile

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=mvcAfrovisiongroup:www.afrovisiongroup.comWikipedia: http://en.wikipedia.org/wiki/Model

%E2%80%93view%E2%80%93controller

REFERENCES

Page 19: MVC(Model View Controller),Web,Enterprise,Mobile

THANK YOU