Most modern applications are based on the client/server architecture, which divides an application into two logical parts, the client and the server. The functions performed by the client and the server can be divided into three categories: user services, business services, and data services.
These services are implemented as logical layers in an application. The user service layer, also called the presentation layer, performs the task of providing an interactive user interface. The business service layer enforces the business rules that define the behavior of an organization.
The business service layer performs such validations pertaining to the business rules of an organization. The data service layer is responsible for managing and manipulating data. Based on the methods used for implementing these three layers, client-server applications are further categorized as single-tier, two-tier, three-tier, and n-tier or multitier applications.
In case of a single-tier or monolithic application, all the functions relating to the user, business, and data service layers are grouped into one logical application module, which might be a single executable file. In a two-tier application, the user and data services are located separately, either on the same machine or on separate machines.
For example, you might have a Visual Basic application, which provides the user interface, and SQL Server 7.0, which manages data. In such a case, the business services might be handled by the client or by the server. In a three-tier application , all the three service layers reside separately, either on the same machine or on different machines.
A multitier or n-tier application is very similar to a three-tier application. An n-tier application uses business objects for handling business rules and data access. It has multiple servers handling business services.
This application architecture provides various advantages over other types of application architectures. Some of the advantages include extensibility, resilience to change, maintainability, and scalability of the application.
Most Web applications are based on the n-tier architecture. In case of Web applications, the browser acts as a client, which makes requests to the Web server for some data. The Web server processes the request and sends the requested data to the browser. You might implement an extra layer between the browser and the Web server for performing business rule validations. This layer can be implemented by using business objects.
In an n-tier application, the business services layer can be encapsulated in various reusable classes, known as business object classes, which can be combined to create precompiled components. Thus, business objects are reusable and interoperable components that perform a specific set of functions. Business objects enable you to build applications that can be easily changed as per the changing requirements of users and the organization. You can also build new applications based on existing components.
This results in reduced development time and maintenance costs. You can also substitute the user and the data services layers without having a negative impact on the working of the business objects. Business objects can be broadly categorized as follows:
User interface (I)-centric business rule objects:
These objects concentrate on validation of user interface components. For example, you may create a UI-centric business rule object to ensure that a text box is not blank. A UI-centric business rule object may also perform some calculations on the data returned from the database.
Data-centric business rule obects:
These objects perform the functions relating to data access such as locating the source of data, sending the necessary commands for retrieving data, manipulating data, and sending the data back and forth between the database and the UI-centric business rule objects. Data-centric business rule objects run faster than UI-centric business rule objects, because the latter often depends on the former for completion of data manipulation and integration.
For example, you might create a UI-centric business rule object that displays the net amount after calculating the sales tax and the discount based on the product price and order quantity. This object might depend on a data-centric object, which establishes a connection to the data server, sends the required commands to the server, and returns the prices and order quantities of products from the database to the UI-centric object. In this case, the UI-centric object has to wait until the data-centric object returns the required data for calculating the net amount.
Creating and Using Business Objects
ASP.NET enables you to easily create your own business objects and use them in Web applications. In this section, you will look at the process of creating a simple UI-centric business object that calculates the sales tax and the discount based on the price of a product. You will also learn to create a data-centric business rule object for establishing a connection and sending queries to the database server.
Creating a UI-centric business rule object
To create a business rule object, follow these steps:
1. Select File ® New ® Project. This invokes the New Project dialog box. Select Visual Basic Projects from the Project Types list box.
Select Class Library from the Templates list box. Name the project CalcNetAmt.
2. In the Solution Explorer window, right-click the Class1.vb file and select Rename from the pop-up menu. Change the name of the Class1.vb file to CalcNetAmt.vb.
3. Create the function CalcAmt() in the class CalcNetAmt and type the following code:
4. Public Class CalcNetAmt
5. Public Function CalcAmt(ByVal dPrice As Double) As Double
6. Dim dNetAmt As Double
7. dNetAmt = dPrice * 1.1
8. If (dNetAmt > 100)
9. dNetAmt = dNetAmt * 0.95
10. End If
11. Return dNetAmt
12. End Function
End Class
This function takes the price of a product as a parameter. It calculates the sales tax as 10 percent of the product price. If the net price after adding the sales tax is greater than $100, a discount of 5 percent is given on net price. The function returns the net payable amount for a product.
13. Compile this class by selecting Build ® Build. When you compile the class, a DLL file is created; this file can be used by other applications.
Alternatively, you can compile this class by typing the following statement at the MS-DOS command prompt:
14. vbc /t:library /out:calcnetamt.dll calcnetamt.vb In this statement, vbc is the Visual Basic compiler. You can use various command-line options with the compiler. The /t option is used to specify the type of output file format to be created by the compiler. You can set this option to exe (console application), library (code library), module (DLL), or winexe (Windows-based application). In this statement, the /t:library option instructs the compiler to create a library assembly.
related post
CREATING ASSEMBLIES WITH ASP.NET
BUILDING HANDLERS IN ASP.NET
INTERFACES AND CLASSES CREATION IN ASP.NET
CACHING IN ASP.NET
CACHING IN ASP.NET PART TWO
WIRE LESS APPLICATION WITH ASP.NET
SECURITY IN ASP.NET PART ONE
SECURITY IN ASP.NET PART TWO
LOCALIZING ASP.NET APPLICATIONS
DEPLOYING ASP.NET APPLICATIONS
ASP.NET CONFIGURATION SYSTEM
WEB SERVICES IN ASP.NET
WEB SERVICES PART TWO
WEB SERVICE INFRASTRUCTURE
WEB SERVICE INFRASTRUCTURE PART TWO
EXCHANGING MESSAGES IN ASP.NET
MICROSOFT HAIL STORM
SOAP AND DOT NET PART ONE
SOAP AND DOT NET PART TWO
These services are implemented as logical layers in an application. The user service layer, also called the presentation layer, performs the task of providing an interactive user interface. The business service layer enforces the business rules that define the behavior of an organization.
The business service layer performs such validations pertaining to the business rules of an organization. The data service layer is responsible for managing and manipulating data. Based on the methods used for implementing these three layers, client-server applications are further categorized as single-tier, two-tier, three-tier, and n-tier or multitier applications.
In case of a single-tier or monolithic application, all the functions relating to the user, business, and data service layers are grouped into one logical application module, which might be a single executable file. In a two-tier application, the user and data services are located separately, either on the same machine or on separate machines.
For example, you might have a Visual Basic application, which provides the user interface, and SQL Server 7.0, which manages data. In such a case, the business services might be handled by the client or by the server. In a three-tier application , all the three service layers reside separately, either on the same machine or on different machines.
A multitier or n-tier application is very similar to a three-tier application. An n-tier application uses business objects for handling business rules and data access. It has multiple servers handling business services.
This application architecture provides various advantages over other types of application architectures. Some of the advantages include extensibility, resilience to change, maintainability, and scalability of the application.
Most Web applications are based on the n-tier architecture. In case of Web applications, the browser acts as a client, which makes requests to the Web server for some data. The Web server processes the request and sends the requested data to the browser. You might implement an extra layer between the browser and the Web server for performing business rule validations. This layer can be implemented by using business objects.
In an n-tier application, the business services layer can be encapsulated in various reusable classes, known as business object classes, which can be combined to create precompiled components. Thus, business objects are reusable and interoperable components that perform a specific set of functions. Business objects enable you to build applications that can be easily changed as per the changing requirements of users and the organization. You can also build new applications based on existing components.
This results in reduced development time and maintenance costs. You can also substitute the user and the data services layers without having a negative impact on the working of the business objects. Business objects can be broadly categorized as follows:
User interface (I)-centric business rule objects:
These objects concentrate on validation of user interface components. For example, you may create a UI-centric business rule object to ensure that a text box is not blank. A UI-centric business rule object may also perform some calculations on the data returned from the database.
Data-centric business rule obects:
These objects perform the functions relating to data access such as locating the source of data, sending the necessary commands for retrieving data, manipulating data, and sending the data back and forth between the database and the UI-centric business rule objects. Data-centric business rule objects run faster than UI-centric business rule objects, because the latter often depends on the former for completion of data manipulation and integration.
For example, you might create a UI-centric business rule object that displays the net amount after calculating the sales tax and the discount based on the product price and order quantity. This object might depend on a data-centric object, which establishes a connection to the data server, sends the required commands to the server, and returns the prices and order quantities of products from the database to the UI-centric object. In this case, the UI-centric object has to wait until the data-centric object returns the required data for calculating the net amount.
Creating and Using Business Objects
ASP.NET enables you to easily create your own business objects and use them in Web applications. In this section, you will look at the process of creating a simple UI-centric business object that calculates the sales tax and the discount based on the price of a product. You will also learn to create a data-centric business rule object for establishing a connection and sending queries to the database server.
Creating a UI-centric business rule object
To create a business rule object, follow these steps:
1. Select File ® New ® Project. This invokes the New Project dialog box. Select Visual Basic Projects from the Project Types list box.
Select Class Library from the Templates list box. Name the project CalcNetAmt.
2. In the Solution Explorer window, right-click the Class1.vb file and select Rename from the pop-up menu. Change the name of the Class1.vb file to CalcNetAmt.vb.
3. Create the function CalcAmt() in the class CalcNetAmt and type the following code:
4. Public Class CalcNetAmt
5. Public Function CalcAmt(ByVal dPrice As Double) As Double
6. Dim dNetAmt As Double
7. dNetAmt = dPrice * 1.1
8. If (dNetAmt > 100)
9. dNetAmt = dNetAmt * 0.95
10. End If
11. Return dNetAmt
12. End Function
End Class
This function takes the price of a product as a parameter. It calculates the sales tax as 10 percent of the product price. If the net price after adding the sales tax is greater than $100, a discount of 5 percent is given on net price. The function returns the net payable amount for a product.
13. Compile this class by selecting Build ® Build. When you compile the class, a DLL file is created; this file can be used by other applications.
Alternatively, you can compile this class by typing the following statement at the MS-DOS command prompt:
14. vbc /t:library /out:calcnetamt.dll calcnetamt.vb In this statement, vbc is the Visual Basic compiler. You can use various command-line options with the compiler. The /t option is used to specify the type of output file format to be created by the compiler. You can set this option to exe (console application), library (code library), module (DLL), or winexe (Windows-based application). In this statement, the /t:library option instructs the compiler to create a library assembly.
related post
CREATING ASSEMBLIES WITH ASP.NET
BUILDING HANDLERS IN ASP.NET
INTERFACES AND CLASSES CREATION IN ASP.NET
CACHING IN ASP.NET
CACHING IN ASP.NET PART TWO
WIRE LESS APPLICATION WITH ASP.NET
SECURITY IN ASP.NET PART ONE
SECURITY IN ASP.NET PART TWO
LOCALIZING ASP.NET APPLICATIONS
DEPLOYING ASP.NET APPLICATIONS
ASP.NET CONFIGURATION SYSTEM
WEB SERVICES IN ASP.NET
WEB SERVICES PART TWO
WEB SERVICE INFRASTRUCTURE
WEB SERVICE INFRASTRUCTURE PART TWO
EXCHANGING MESSAGES IN ASP.NET
MICROSOFT HAIL STORM
SOAP AND DOT NET PART ONE
SOAP AND DOT NET PART TWO
No comments:
Post a Comment