Creating an Application Development Framework Using Enterprise Templates - Part 1, Page 2
Structure of Enterprise Templates
The templates in Visual Studio .NET contain an initial project structure component, which is essentially the starting point for a software architect to begin building an application. The component can include reusable software components, classes and other pieces of technology. Templates also contain the policy associated with the project, in which an architect can outline which technologies a developer should use when creating the applications.
In VS.NET, Enterprise Templates consist of three major components:
- An application template, which defines the initial project structure (base files, BCL assemblies that are included, etc.). You can draw analogies between the application template and the Active Template Library (ATL) from VS6. When you create a project in ATL the environment gives you some basic boilerplate files (the IDL, co-class files, .h files, etc.). Similarly, you can define what boilerplate files a user gets when they create a new project based on your template.
- A policy file, which allows you to customize the VS.NET environment to a significant degree. The policy file is defined in TDL, which is used to specify the technologies that are appropriate at various points in a project. TDL also provides fine-grained control of property settings. For example, you can institute a policy that disables the managed C++ compiler and refuses to import certain BCL libraries such as System.Remoting. You can also configure certain compiler options (e.g., disallow unsafe code) using policy files. TDL also enables an architect to control the Visual Studio .NET environment, including the task list, toolbox, property browser, solution explorer, designers and editors, and even dynamic help. When a developer uses the template project, its associated policy is automatically applied within the context of the Visual Studio .NET environment. Policy can even be attached to pre-existing projects, with any violations referenced in the task list for easy correction.
- Custom help topics — Using custom help topic files, you can provide guidance to the application development teams right within Visual Studio .NET IDE.
A Quick look at Template Description Language (TDL)
An Enterprise Template is built using an XML grammar that specifies the projects, items, and constraints that comprise the template definition. The grammar elements in this table comprise the Template Definition Language (TDL) and represent the available grammar elements for constructing Enterprise Templates.
Enterprise Template Framework
In this article, we will customize the enterprise templates to come up with our own enterprise application template that can be used as the starting point for building web-based E-Commerce applications. While defining the template, we will also standardize on the common base application architecture that we want to establish in all of our applications. Along the way, we will also define the application building blocks (that provide services such as Exception Management, security, data access and so on) and implement them as part of the template.
Before we start customizing the enterprise template, let us take a quick look at the application components of a typical .NET enterprise solution.
As you can see from the above diagram, a typical .NET enterprise application is partitioned into logical layers based on their functionality. For example, all the business logic for the entire application is contained in the business logic layer, allowing us to encapsulate the business logic in the form of reusable components. Let us briefly define the different components of the above architecture.
- User Interfaces:
This layer is responsible for rendering the appropriate user interface for our application. Since our template is focused on web-based applications, normally these layers will be composed of one or many ASP.NET web applications.
- Web Services layer:
This layer consists of web service methods that allow us to expose the functionality to external consumers using XML over HTTP and SOAP.
- Business Fagade layer:
This layer consists of components that allow us to provide a consistent interface into the business logic layer. This layer depends on the business logic layer for all of its functionalities. This is normally created by Visual C# class library projects.
- Business Services layer:
This layer again consists of Visual C# Class library components that contain the core business logic for our application.
- Data Services layer:
This layer consists of ADO.NET Code to invoke the stored procedures or execute SQL statements in SQL Server 2000. The data services layer will leverage the data access application block from Microsoft for executing queries and stored procedures against the Sql Server database. We will add the data access application building block as part of the framework in the later stages of this article.
- System Framework projects:
These set of components provide the core services for our application and will be shared by all the layers of the application.
- SQL Server database:
The SQL server database contains all the stored procedures.
Now that we have seen the different components of our application architecture, let us take a look at the building blocks that we want to include as part of the template. Once defined, these building blocks will be part of every new application that is created by choosing CustomDistributedAppTemplate as the template.
Implementation of System Framework
In this section, we will create the system framework components that are shared by all the layers of the application. As we already mentioned, we will cover the following 4 components.
- Data Access Application block
- Exception Management Application block
- Custom Configuration file section handling classes
- Classes that provide encryption and decryption functionalities
Let us look at the creation of data access application block.