Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Articles
Search: 

TierAdapter Framework - Part 1
Ruben Rovira, June 1, 2005
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 t...
Summary
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.
Description

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
Next time you won't need to indicate the path, since this path, and other required paths, will be added to the search path.

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:

  • A presentation window (Splash Screen)
  • A dynamic menu (for the options that belong specifically to the application)
  • Basic security schema, by roles/users
  • A toolbar that implements the basic operations
  • Simple data entry forms
  • A data-entry form with parent-child relations
  • Some reports

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:

  • Create a new record
  • Open an existing record
  • Save the current record
  • Delete the current record
  • Close the form
  • Print the current record
  • Send the current record to preview
  • Export the current record
  • The three basic Clipboard operations (cut, copy, paste)

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.

Ruben Rovira, Desarrollos Independientes
Rubén O. Rovira, (Buenos Aires, Argentina), is a Computer Bachelor. He is devoted to development of custom software for commercial and service companies since 1992. He has used FoxPro and Visual FoxPro as a development tool since version 2.5 (DOS). Nowadays he is an independent Information Systems Consultant, and Lead Developer of the TierAdapter Framework.

Omar Bellio, Soluciones Informáticas
Omar Bellio is a system analyst and independent developer since 1985. He has worked with Fox since its very first version. Today he develops applications for a variety of purposes using Microsoft tools (VFP, VB, .NET PLATFORM, SQL Server, etc.) and also Oracle.
More articles from this author
Ruben Rovira, May 1, 2003
In this article I will talk about ASP.Net mobile controls, and how to use them to puch the functionality of our applications to the domain of mobile devices such as cell phones and PDAs. I will also create a simple web mobile application as an example, using a component developed in VFP8 to sh...
Ruben Rovira, September 1, 2002
In this article we shall see how to use images in forms and reports, in our applications developed with Visual FoxPro. We will also talk about how to optimally organize and save images on disk. Introduction How often have we, as developers in the DOS era, desired to have the possibility t...
Ruben Rovira, July 1, 2005
In this second issue of the series about the framework, we review the Demo application, the way it works and the main features it provides, so in the future issues we can explain how to implement a solution.
Ruben Rovira, September 1, 2005
In this issue, we will continue with the creation of the layers for an entity that includes more than one table, in a header-detail schema; as we shall see, also in this case, the required code is minimal.
Ruben Rovira, August 1, 2005
In this new issue, we will show the steps to follow to develop an application from zero. Also, as mentioned at the end of the previous issue, we will demonstrate that very little code has to be written in order for everything to work correctly.
Ruben Rovira, December 1, 2005
This time, we will briefly make a detour from the transactions (until the next issue), and look at different ways in which the framework allows us to distribute application components. This will serve as a basis, so that we can later analyze how to use transactions in every one of these cases.
Ruben Rovira, October 1, 2005
The basic idea is to place, within a Try/Catch block, a call to any process that might generate an exception (is there any process that can't?). When the exception is generated, it will be trapped by the Catch command, and processed differently, depending on the tier where it happens. The tier which...
Ruben Rovira, November 1, 2005
Any database engine, in order to be worthy of receiving this designation, should offer the possibility of handling transactions. The appropriate handling of transactions (among other things) allows us to guarantee the integrity of the stored data. For those with less experience in this subject, I sh...
Ruben Rovira, April 1, 2003
In the following paragraphs I shall try to summarize what web services are and later, step by step, I'll explain how to create a web service usign VFP8. This web service will be used in the third part of this note where, always from VFP8, we'll develop a small application that will consume the ...