Datasheet

7
Chapter 1: A Framework for Enterprise Applications
The BLL contains all the business and validation rules that are the real “brains” of the application. For
example, suppose you have a screen that allows the user to create a user in the system. The user’s name is
required and must be unique when adding a new user. You could put logic in the web form that enforces
these two rules. Now suppose a new requirement comes along: The application must import a comma-
separated file of user names. The user name is still required and must be unique, so that logic would
have to be duplicated in the import logic. If you were to put the logic in a class, then the web form and
the import program could call the same code. Anytime new rules are added to the application, you
would simply change the logic in the shared class. This makes code maintenance much easier.
The third layer is the DAL, which contains the logic to connect to the database, to call stored proce-
dures, or to execute SQL statements. The DAL developer usually understands the intricacies of SQL
and can optimize queries. One reason to create a DAL is that it is easier to migrate from one database
type to another without affecting the rest of the application. Suppose you started out using an Access
database for a small company. As the company grows, you realize that Access isnt scalable enough and
you need to migrate to SQL Server. If all of your database logic is in the DAL, then all you should need
to change is the DAL. Another reason to separate logic into a DAL is because your application may need
to support more than one database type. This is a common occurrence for third-party applications that
need to support SQL Server and Oracle, depending on their client’s requirements.
Conceptually, the three-layer architecture looks like the diagram shown in Figure 1-1.
User Interface
ASPX Pages, Custom Controls,
JavaScript, StyleSheet, Master
Pages
Business Logic Layer
Business Object, Lists, Validation
Rules
Data Access Layer
Data Classes
Database
Figure 1-1
96865c01.indd 7 12/17/08 2:06:03 PM