Book Image

Sencha MVC Architecture

By : Ajit Kumar
Book Image

Sencha MVC Architecture

By: Ajit Kumar

Overview of this book

<p>Sencha provides one of the most popular frameworks to build RIA applications (using ExtJS) and HTML5 compliant mobile applications (using Sencha Touch). Creating an application is always easy, but creating a highly maintainable and scalable application is challenging without having solid architectural practices in place.<br /><br />"Sencha MVC Architecture" covers all the aspects, from project design to building and packaging, creating and delivering an enterprise-class application by applying Sencha MVC Architecture. Every concept is supported with a functional code, which you can quickly try out and also understand how it works.<br /><br />The book presents the general MVC architecture and presents a case for the client-side MVC architecture and their importance. You will learn why we need to have client-side MVC architecture and how the concepts map to the Sencha MVC Architecture. You will then learn how to create an application in ExtJS as well as Sencha Touch by applying all the concepts and classes of Sencha MVC Architecture. The step-by-step approach helps you build a working application without getting into the detail of the constructs yet explains how things work. The later part of the book will explain the Sencha MVC Architecture constructs in detail &ndash; class system, loader, controller, etc. and the best practices introduced by the framework. The end of the book will walk you through the challenges that you will face when you model your application using the Sencha MVC Architecture and also show you how to overcome each one of them. You will learn how to make use of the tools to manage your project beginning from the project creation to delivery.</p>
Table of Contents (12 chapters)

Preface

Model-View-Controller is a popular architecture among the software developers to build scalable and maintainable applications. While most of the time we use the server-side MVC architecture, with the complexity increasing in the Rich Application Development, a similar architecture is needed on the client-side, as well. The client-side MVC architecture allows us to de-couple the presentation from the model and the controller logic. The newly introduced client-side MVC architecture in Sencha's two frameworks —ExtJS and Touch—offers a great way to model applications where we can leverage the benefits of the architecture, and also with the Sencha SDK Tools we can manage the complete project—from creation to build and packaging—effectively. This, on one side, helps us to develop an application by following the MVC architectural principles, project structure, and coding guidelines while, on the other side, it optimizes our build and packaging for the Web.

What this book covers

Chapter 1, Sencha MVC Architecture: This chapter describes the MVC architecture and outlines the need of having an MVC architecture implemented on the clientside, which runs inside a browser. The chapter shows how to model an application without using Sencha MVC architecture and look at the demerits of that modeling. It then reviews the benefits that one can get by following Sencha MVC architecture. Subsequently, it visits the classes in ExtJS as well as Sencha Touch, which map to the model, view, and controller.

Chapter 2, Creating an Application: In this chapter we look at a sample application and learn how to model it as per the MVC architecture and map the different building blocks to the classes provided by ExtJS and Sencha Touch. The application development involves how to identify the views, models, and controllers in an application, how to make use of multiple controllers within an application and pass the data and control between them to achieve the overall application behavior. At the end, we look at some of the rules related to class naming convention, folder structure, and so on, which is required to get the application up and running.

Chapter 3, Building Blocks: This chapter covers the different classes, which are part of the MVC architecture in ExtJS as well as Sencha Touch. It covers the function of each of these classes and the differences in their behavior and usage. In addition to the common classes—Application, Controller, Model, View (Component)—it also covers the Touch-specific way to handle profiles to encapsulate device-specific behaviors and layout in the applications. Also, it shows how to set up the routes in Touch application and have the history tracking in place.

Chapter 4, Class System: This chapter explains how the new class system works and what are the functionalities offered by the class system. It also covers what are the naming conventions put in place and recommended by the framework, how to define classes, set up dependencies, implement inheritance, enhance capability using mixins, create singleton classes, and so on.

Chapter 5, Challenges and Solutions: This chapter reviews some of the main challenges when it comes to developing an MVC-based application – project creation, build, debugging, and packaging. With the challenges at hand, the chapter then covers the Sencha SDK Tools to show how this tool can help us address each of those challenges.

What you need for this book

To run the examples in this book you will need the following software:

  • Eclipse 3.3 or above with JEE (for example, Helios) and JavaScript (JSDT) support

  • Oracle Java JDK 1.5 or above

  • ExtJS 4.1 library

  • Sencha Touch 2.0 library

  • Android SDK

  • ADT Plug-in

  • Apache Tomcat 6.0 or above

Who this book is for

This book is for someone who wants to understand the Sencha ExtJS and Touch frameworks, in general, and the Sencha MVC Architecture, in specific, to create scalable and maintainable applications. The book provides a complete end-to-end implementation of an application using the Sencha ExtJS as well as Sencha Touch frameworks by applying the Sencha MVC Architecture. The book is also useful for someone who wants to understand how the Sencha SDK Tools work and how one can set up an effective project management through project setup and build management.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "Profile functionality is offered by the Ext.app.Profile class."

A block of code is set as follows:

{
  success: true,
  users: [
    {id: 1, name: 'Sunil',  email: '[email protected]'},
    {id: 2, name: 'Sujit', email: '[email protected]'},
    {id: 3, name: 'Alok', email: '[email protected]'},
    {id: 4, name: 'Pradeep', email: '[email protected]'},
    {id: 5, name: 'Ajit', email: '[email protected]'}
  ]
}

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Create a Dynamic Web Project workspace in Eclipse".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title through the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website, or added to any list of existing errata, under the Errata section of that title.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.