Skip to content

Instantly share code, notes, and snippets.

@gregbarry
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregbarry/50b984bd3de71de7d3fd to your computer and use it in GitHub Desktop.
Save gregbarry/50b984bd3de71de7d3fd to your computer and use it in GitHub Desktop.
Disclaimer
#Introduction to Application Architecture
Ext JS provides support for both MVC and MVVM application architectures. Both of these
architectural approaches share certain concepts and focus on dividing application code
along logical lines. Each approach has its strengths based on how it chooses to divide
up the pieces of an application.
The goal of this guide is to provide you with foundational knowledge regarding the
components that make up these architectures.
##What is MVC?
In an MVC architecture, most classes are either Models, Views or Controllers.
The user interacts with Views, which display data held in a Model. Those interactions are
monitored by a Controller or the Model's business logic, which then responds to the
interactions by updating the View and Model, as necessary.
The View and the Model are generally unaware of each other because the Controller has the
sole responsibility of directing updates. Views typically have little (if any) business
logic, and Models are primarily an interface to data that allow for business logic
regarding changes to said data. Generally speaking, Controllers will contain most of
the application logic within an MVC application.
One of the main advantages of an MVC architecture in web applications is that it helps to
avoid enormous files full of spaghetti code. The goal of MVC is to clearly define the
responsibilities of each piece of the application. Because every class (i.e. every file)
has clearly defined responsibilities, they implicitly become ignorant of the larger
environment – making the app easier to test, easier to maintain, and allowing
code to be reused.
##What is MVVM?
The key difference between MVC and MVVM is that MVVM features an abstraction of a View
(the ViewModel), which manages the changes between a Model’s data and the View's
representation of that data (i.e. data bindings) – something that can be
cumbersome to manage in traditional MVC applications.
The result is that the Model and framework perform as much work as possible, minimizing
or eliminating application logic that directly manipulates the View.
##Returning Users
Ext JS 5 introduces a new MVVM architecture as well as a new take on the (C) in MVC.
That said, it is important to note that the classic Ext JS 4 MVC implementation will
continue working in the same manner. We DO encourage you to take advantage of our exciting
new functionality, but you shouldn't feel obligated to restructure your application.
**Note:** Sencha Cmd's starter app, produced by `sencha generate app`, currently produces
an MVVM structure. However, you can simply delete the default viewModel to continue
building your application as before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment