Sencha has advanced ExtJS over the last several years. While many
improvements were implemented, the introduction of MVC – model, view, controller
pattern - has greatly added in code maintainability and in creating clear
separation of concerns. The model represents an entity, an object where the
fields of the entity are defined. The view concentrates on providing a
definition of visual components. The logic then is handled in the controllers.
Given this breakdown, let’s look at the controllers and the
views. The controllers in the MVC are singletons which means there is only one
instance of any given controller in the application. Then that instance is responsible
for handling, what may often be, a complex view, consisting of many components
and sub views. Since all the logic and event handling is done in the
controller, the class can become quite big. It becomes an art to know how to
best break down the complexity of one controller into multiple ones. However,
aside from that, what emerges as a bigger problem is the ability to unit test
the controller. Singletons, as we know, are not unit test friendly.
Additionally, traditional ExtJS controllers don’t support injecting
dependencies that would provide an ability to use mock data on demand.
This is where DeftJS can help. DeftJS is a component that
works with ExtJS and provides extra functionality including dependency
injection. Controllers in DeftJS are light view classes that are view specific.
By default, they are not singletons (but they can be if desired). Specific
views are controlled by controller classes, which are destroyed when
views are destroyed. This modular approach, coupled with the dependency
injection, provides much better support for unit testing ExtJS applications.
Sencha has endorsed DeftJS by including DeftJS
documentation on its website and presenting DeftJS at the Sencha Con.
More information can be found at:
No comments:
Post a Comment