I have found that the 2.5 Tier design to work best for the new web applications I have created.
I typically start off with 2 class libraries and 1 web application.
Company.Data (Class library)
Company.Web (Class library) (Contains PageBase, Custom Controls, Helper functions, etc)
Company.Web.WebApplication (Web Application)
For applications that I have created, I only use stored procedures to access the data.
In fact, I have created CodeSmith templates to generate all of the stored procedures, data and business classes.
Company.Data
This assembly consists mainly of the entity data classes and collections.
For example, I typically have a table called Settings in my web applications.
A class called Setting and SettingCollection will be generated.
So if I need to load a specific setting, I can do this..
Dim setting As New Setting(1) 'pass in the id of the specific setting
setting.Value = "False" 'change the value
setting.Save() ' Call the save method to persist changes back to the database
or to create a new setting, I just do not pass a value in the constructor
Dim setting as New Setting()
setting.Name = "SmtpServer"
setting.Value = "localhost"
setting.Save()
My namespces in the copmany.data assembly typically look like this..
Company.Data.Entites
Company.Data.Collections
Company.Data.BusinessObjects ( This namespace is used to create custom methods to access data)
I also generate custom methods based on primary keys, foreign keys, and unique indexes.
For example, the name column in the settings table has a unique index.
A shared method called GetSettingByName will be generated automatically and this will return a setting object.
This method would be in the Company.Data.BusinessObjects namespace
For the entity and business object classes, two files are generated. 1 that is generated each time and 1 that is editable and only generated
the first time. I use partial classes to allow me to add custom code with out it being overwritten.
For me, this methodolgy has worked really well. Codesmith generation saves me countless hours of coding. I can add 5 new columns to a table, regenerate
all of the new code in seconds. Stored procedures will be dropped and recreated.
The 2.5 tier design works well because my application is only going to use one database and that is Sql Server. The need to use access, oracle, mysql in the future wont happen.