Book Image

Mastering ExtJS - Second Edition

By : Loiane Avancini
Book Image

Mastering ExtJS - Second Edition

By: Loiane Avancini

Overview of this book

Table of Contents (19 chapters)
Mastering Ext JS Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a Model


As usual, we are going to start by creating the models. First, let's list the tables we will be working with and their columns:

  • Actor: actor_id, first_name, last_name, last_update

  • Category: category_id, name, last_update

  • Language: language_id, name, last_update

  • City: city_id, city, country_id, last_update

  • Country: country_id, country, last_update

We could create one Model for each of these entities with no problem at all; however, we want to reuse as much code as possible. Take another look at the list of tables and their columns. Notice that all tables have one column in common—the last_update column.

All the previous tables have the last_update column in common. That being said, we can create a super model that contains this field. When we implement the actor and category models, we can extend the super Model, in which case we do not need to declare the column. Don't you think?

Abstract Model

In OOP, there is a concept called inheritance, which is a way to reuse the code of existing...