Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

The Baker's Dozen: 13 Productivity Tips for Building a .NET Distributed Application

The Common Ground Framework for .NET provides a set of starter classes for building database applications in a distributed environment.


advertisement
his installment of "The Baker's Dozen" presents a Windows Forms database application that demonstrates some of the primary attributes of a distributed architecture. These attributes include authentication and connectivity, data management, business objects, user-interface modules, and reporting. The featured application is a job-costing and invoicing application for a Masonry company, and is available for download. The application contains many functions that are required in most business applications. This article steps through the construction of these key pieces and provides classes and methodologies that you can apply to your next application.

Beginning with the End in Mind
When I started working in .NET, I longed for a small but meaningful demo application that addressed the challenges and requirements that I faced as an applications developer. After I became productive in .NET (thanks too many authors and on-line community leaders), I made a promise to build a Web-based, smart-client business application to serve as a knowledge base for others facing the same learning curve I experienced.

The Common Ground Framework provides capabilities to use multiple connections/databases without changing the software or swapping configuration files.
Along the way, I also decided to build a set of reusable classes that represented the common functionality across the .NET systems I've built. In the spirit of my company name and philosophy, I'm calling this set of classes the Common Ground Framework for .NET. Thus, I've combined my own knowledge, techniques, and experiences with questions I've seen posted on technical forums to drive the content of this demo—and hopefully increase your productivity.

The demo application is based on the job-costing and invoicing needs of a typical contractor company. Many of the features I discuss apply to almost any application type. Thus some of the features may seem very familiar to you. In addition, I've also added some features specifically for demonstrative purposes.

The application utilizes concepts from previous Baker's Dozen articles (DataGrid, Crystal Reports, and Transact-SQL). Each tip focuses on a particular requirement in a distributed database application, and offers either reusable classes and/or methodologies for handling the situation. I will cover the following topics:

  • An overview of the primary pieces of the architecture, and the major tasks that each piece will perform
  • An authentication form class that prompts for user ID and password, database (test DB, production DB) and connection type (Web Service over HTTP, Remoting via TCP)
  • Developing server-side Web service and remoting server interfaces so that client pieces can access the back-end
  • Baker's Dozen Spotlight: developing client-side code to access the back-end through the Web services/remoting service interfaces referenced above:
  • A data access layer for executing stored procedures against a requested database
  • A one-way synchronization approach for managing lookup tables, to minimize network traffic
  • A basic MDI Parent form class with data-driven menus and a status bar that displays system information
  • A set of subclassed Winform controls to extend base functionality
  • A generic interface to bind ADO.NET data with these controls
  • A generic form class with base functions to handle standard data maintenance tasks
  • Examples of server-side and client-side business objects to validate data and enforce rules
  • Baker's Dozen Potpourri: several advanced uses of ADO.NET functionality
  • An implementation of basic audit trail functionality to track database changes, and to allow users to view the changes
With each tip, I'll discuss the areas of the architecture (Web service, client-side, and so on) that are affected.

You can download all the code listings for this article. So once again borrowing from the theme of Van Amsterdam's bakery, I bring you thirteen productivity tips, in a new "Baker's Dozen."

 
Figure 1: The Masonry Solution project.
Tip 1: Planning the Architecture
The demo application contains six components:

  • Client piece
  • Web service proxy/remoting interfaces
  • Web service/remoting server
  • Business objects
  • Data access layer
  • Back-end database (SQL Server)
Table 1 lists the namespaces for the CG Framework classes. Table 2 lists the namespaces for the invoicing application that uses the framework. The download project contains a single solution (see Figure 1) with 19 projects.

Table 1: Common Ground Framework namespaces.

Namespace

Classes



Description

CGS.Business

cgsBaseBizObject

Base business objects

CGS.CrystalReports

cgsCrystalViewer

cgsCrystalManager

Tools for generating Crystal Reports

CGS.DataAccess

cgsDataAccess

Base Data Access Class

CGS.Globals

cgsGlobals

System-wide static properties

CGS.RemoteAccess

cgsClientRemoteAccess

Returns generic communication object that can be cast to a Web service or remoting interface

CGS.Utilities

cgsUtilities

Miscellaneous utilities

CGS.Winforms.Controls

cgsControls

Subclassed controls

CGS.Winforms.Containers

cgsContainerCriteria

cgsContainerResults

cgsContainerDataEntry

Base containers for data entry, result sets, and selection entry criteria

CGS.Winforms.Forms

cgsFrmDataMaintenance

cgsFrmLogin

cgsFrmAuditTrail

cgsFrmMDIParent

Base forms for data maintenance, login, audit trail, and MDI parent


Table 2: Masonry Invoicing application namespaces.

Namespace

Masonry.Client.Winforms

Masonry.Data.Access

Masonry.DataSets

Masonry.Interfaces

Masonry.Local.BusinessObjects

Masonry.RemotingServer

Masonry.Reports

Masonry.Server.BusinessObjects

Masonry.Webservice

Masonry.Winform.Containers


The client piece contains a rich UI for retrieving and updating data, and reporting capabilities using Crystal Reports. The client communicates with the back end using either Web service references or remoting interfaces. Interfaces provide tremendous value in distributed computing by guaranteeing that back-end classes will contain specific properties and methods. The client piece contains a set of classes and interfaces to simplify back-end access.

The back-end uses either Web services or a remoting server to respond to client requests. While many corporations use Web services for distributed computing, some prefer the increased performance and security of TCP remoting. The demo application supports both. The Web services/remoting server will work with business objects and then data access classes to save/retrieve data from SQL Server, and return result sets to the client. The data access class contains several reusable functions to simply common data tasks.

The application will make extensive use of datasets. Tasks such as data binding, data views, XML integration, reporting, and many other data maintenance tasks are significantly easier with datasets. However, because of the overhead associated with datasets, the application will create an XML string representation when passing dataset contents across physical boundaries/domains.

Author's Note: The code listings in this article are written in C#. In recognition that roughly half the .NET developers use VB.NET, the downloadable project on www.commongroundsolutions.net contains a separate zip file containing VB.NET code for the listings.




Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date