TierAdapter is an n-tier application development framework developed in Visual FoxPro. Briefly, it implements a hierarchy of classes that makes it possible to quickly develop components for the data access tier, easy to change between the native VFP engine and SQL Server or other engines available through OleDB or ODBC; for the business tier; and for the tier of services for the user interface.
Its main characteristics are to maintain a highly disconnected and abstract model, where the database is only accessed when needed, and where the business logic doesn't need to have any significant knowledge about the underlying relational model (although it may reflect this if it happens to be convenient).
Finally, the physical implementation model considers the possibility of changing from a monolithic executable to distributed DLLs in Component Services (COM+) through a change in a property and the corresponding compilation.
This article will be a general introduction where we aim to present the general features of the framework and a brief review of the sample application provided, based on the Northwind database. In the following articles we will give more details about the general architecture, the additional features, and we will describe some of the techniques on which the framework is based.
A little bit of history
The framework arose from the growing need that we saw when giving presentations about n-tier architectures in Visual FoxPro. Normally we used isolated examples about how to communicate the data between the tiers, and we explained some general concepts, but the public always asked about more concrete cases or complete applications. Finally we decided that it would be best to develop a small framework on which we could construct a small, but relatively complete, sample application.
Once we had done some development, and during the stabilization phase, a number of small projects appeared in which the conditions of time and complexity were convenient to use our creation in the real world. The sample application based on the Northwind database (in VFP or SQL Server) was actually built after having released the first versions of some real applications, one of them for the United Nations Development Program (UNDP).
We finally started doing presentations about n-tier architecture in several places in Argentina and Latin America, and even in Canada, during DevTeach 2004 (and we will present it again at DevTeach 2005). The experience was not only valuable, but the audience also appreciated the fact that we satisfied its desire to see a complete application.
The project is released as Open Source under the MIT license, and can be found at SourceForge. Currently several dozens of independent developers and teams (mainly in Latin America) are creating applications with TierAdapter, which has attained an acceptable level of maturity, although we still have an ambitious plan to introduce improvements. Support is given mainly through the SourceForge forums, both in Spanish and in English. We are also proud to be the first Visual FoxPro project to be hosted at SourceForge (it was our "fault" that Fox was added to the list of languages).
Clarification: The last version available is 2.2, which requires Visual FoxPro 9.0. Anyway, we have published a version 2.19 which supports Visual FoxPro 8.0 and has almost the same characteristics; but future versions will require VFP 9 as a minimum.
Presenting the sample application
As noted before, the sample application is based on the Northwind database, which we chose because it was available both in VFP and in Microsoft SQL Server; therefore, it is useful to show how to change from one to another, and it even shows some inconveniences that are resolved in the example and which can appear in other cases. Mainly, Northwind is not a good example to follow with respect to design, therefore, the framework tolerates some bad practices which we may encounter when we have to develop on top of a database that we didn't design ourselves.
The purpose of the application is to be used both as a learning element, and as a template to develop new applications. Perhaps one of the most important characteristics is to see how little code belongs to the application itself; most of the work is done in the framework itself.
If you want to try the framework out, download the ZIP file from SourceForge, uncompress it into a folder (you will note that the contents is source code) and then, from Visual FoxPro, locate the folder which you just created, change to its Demo folder, and then execute the following command in the command window:
do Source\Main
The main screen will look more or less like this:
Figure 1: The desktop of the demo application
Obviously, the central image, the menu, and all other aspects of the application can be changed. The visual aspects in general are customized through framework subclasses, and the most functional ones, like the menu, are based on data, and generated dynamically.
In summary, the components included in the sample application are:
Don't expect a very sophisticated application. What we have implemented are maintenance forms for Product and Client, and one for entering Sales Orders. We believe that this is more than enough to understand how to work with the framework. We will next include some screenshots of the forms. We captured the entire screen, so that you can see the toolbar in different states of enablement.
Figure 2: The product form
The toolbar icons, from left to right, correspond to:
Figure 3: The client form
Note how the enabled state of the icons changes when being in a wait mode. The buttons for printing, preview and export are still enabled, but the output is a report for all the records, instead of the current one.
Figure 4: The selection form
This component makes it possible to define specific search criteria for each entity (in the sample application, for products, clients and orders). Here you can see the result of applying this criterion:
Figure 5: Selection list
This list presents the classical features expected, such as sorting by column and incremental search, but also, as you can see, the items found are separated by pages (similar to the results in Google, for example). This mechanism makes it possible to control the bandwidth consumed by these queries. It will also increase the speed perceived by the user.
Figure 6: Order form (header)
Figure 7: Order form (detail)
We hope that these forms give you a general idea of what you can expect in the framework, with respect to its functionality. As we said before, the example is neither complex nor sophisticated, but it has many of the elements which you will find in a real-life application, therefore, it should not be difficult to extend it to larger solutions.
On the other hand, it should be remembered that the framework is licensed as open-source, therefore, you can modify it as much as you required, and of course, in case you add important features, you will be welcome to contribute them to the project, in order to incorporate them to the general distribution (we won't forget to mention your name on the site).
Conclusions of this first part
Up until here, we have only presented the sample application, leaving out even such general features as security and report management.
In the next article we will see some of these features in more detail, and we will analyze the configuration and code in this example. We will see that we really have to do very little for it to work. In the following articles we will see alternatives of physical distribution of this application (as a single EXE or as remote COM+ components), and then we will study the internal coding of the framework, so that you know how to extend it, or where to search if you have any problem.