Smart client architecture

Smart client is more than a fancy moniker for Win Forms, or a marketing ploy to sell Visual Studio 2005.

Data solutions for disconnected applications

“Smart client” is more than a fancy moniker for Win Forms, or a marketing ploy to sell Visual Studio 2005. It is an architecture that allows Win Forms applications to function when they are disconnected from the network and their primary data source.

Smart client is not a new concept. Back in 1996, during my PowerBuilder days, I remember the Sybase team pushing disconnected Windows applications. Today it is an idea whose time has come.

Smart client design considerations

A smart client application can run on a network database or a local data store running on the same machine as the application. The application should function the same in either mode. That means all necessary data must be cached locally and a synchronization method must be available to update the primary database when the application is connected again. When deciding on a client-side data store, there are several considerations.

Licensing could be an issue if you are building a commercial software product, in that the cost of the license must be factored into the sale price of the product. An unlimited distribution license may be available, but can be expensive. In the corporations for which I’ve worked, this kind of per-seat expense could only be justified for departments such as sales and finance.

If your application is commercial software, ease of installation will be a primary consideration. You’ll need a way to install the product on any supported operating system, and it must co-exist with software typically found on a user’s workstation.

If you’re developing a corporate application, workstations may be free from games and poorly written screen savors, but your solution must still function within certain desktop standards. Your solution might also need to be certified by the people constructing your installation images.

Whether commercial or corporate, sometimes software fails and the database/data store is to blame. So consider how much knowledge there is within the group that will support the product, as well as the level of support available from the vendor. Does the vendor have open support? Is a contract required? Is the fee structure per incident or per hour? What hours and/or days is tech support available? Remember that you could be sitting at your desk on New Year’s Eve because a member of the board of directors has a database problem and you can’t leave until it’s fixed.

Security is another concern. There are two threats to your application’s data when it is sitting on a client’s laptop. One comes from hackers attempting to obtain data from the data store. This is a very real threat and has been heightened by corporate espionage. The second is the unsecured laptop itself. Why try to hack a corporation’s firewalls and security if its sales figures walk out the door each night on someone’s laptop? At home that laptop is likely connected to the Internet via an unsecured, high-speed connection, and its data is there for the taking.

A security concern that is largely unintentional but corrupts data just the same is user tampering. Some people can’t help digging around on their computers, trying to determine how things work. They find your Access database and, with their Access software, start prodding through the tables or text files. It won’t take much to corrupt your data.

Finally, consider the volume of the data and the scale of the system. If you have 50 or 60 data elements and only a few hundred rows need to be cached per element, then you’ve got an open hand to look at different solutions. If you need to cache hundreds of thousands of rows of data, you will need a high-performance data store to keep your application running in a disconnected state.

Technologies to employ

Below are options to consider for building smart client applications.

MSDE – The Microsoft Data Engine is the often-forgotten stepchild of SQL Server 2000. It’s a solid technology but lacks the admin and authoring tools of the standard SQL Server 2000 installation. It can also be cumbersome to install correctly on a client machine. Because it’s free, there are no licensing concerns, and it supports high-volume data applications. Unfortunately, it’s easy for a hacker to find and get at the data.

SQL Server 2005 Express – This new version of MSDE is much improved. While it also lacks many of the capabilities of the full SQL Server package, the Express edition is not totally impoverished when it comes to management and authoring tools. When it is released, it will be good for high-volume apps, but will probably be an easy target for hackers as well.

SQL Anywhere – This is a product from Sybase. I mentioned earlier that I first heard about smart client in 1996. Sybase was pushing the concept, and SQL Anywhere was the product behind it. Like SQL Server 2005 Express, this is a robust database. It offers a tremendous number of features, including full data encryption. It is, however, one of the pricier options available.

Access – The price is right, and you don’t necessarily need Access to create an Access database, although it helps. You are likely to have someone on your team with a strong Access background as well. Scalability is limited, however, so Access should not be considered for a high-volume data application. You can password-protect the file, but the meddle factor is high. If security is a concern, remember that your data is packaged in a self-contained file that’s easy for a hacker to download.

Vista DB – Vista DB 2.0 is a .NET database that deploys with your application as a set of DLLs. It supports the SQL-92 standard and provides a complete set of data access components that mirror the ones Microsoft provides for SQL Server and Oracle. This is a robust database solution capable of handling moderate data loads. It requires no installation beyond simple x-copy. The license allows for free unlimited distribution. While not a free solution, it is cost-effective and feature-rich.

XML – Because you have to write this solution yourself, it is the most time consuming. You can store your application data in XML form in flat files on the client machine. You have granular control over how the data is stored, and once you load the document in an XML Document object, you can use xPath queries to get at your data. Unless you encrypt your XML data files, they will also be subject to hacking and meddling.

Datasets – This is another XML option, but it has some advantages over writing the solution from scratch. It’s easy to move data from your connected network data store to the client: Simply populate the dataset and have it save the XML on the client machine. When you disconnect, create a dataset and have it open the XML file. From there you can simulate SQL functionality using dataviews to filter and sort data. Datasets maintain the state of data for you, so when you are connected again it’s easy to load the dataset with the changed data and send it to the main data store.

Conclusion

Building a smart client application is a lot of work. It also has many implications, so it should only be considered when an application must be able to function offline. To be successful in creating this type of application, understand that the devil is in the implementation details.