Hey all,
What's the standard practice for implementing a 3 tier architecture with asp.net? i've tried to seperate my business and data layers, but im struggling with the communication between layers - since I can't pass the business object by ref to the data layer because that causes a circular reference between the libraries.
So I tried creating another library of interfaces, so:
Project.Business references Project.Business.Interfaces, Project.Data
and
Project.Data references Project.Interfaces
then
Project (presentation) references Project.Business
This did the trick to a point, but im now encountering problems with it, for instance take the following method:
The problem there is that I cannot initiate a instance of an interface to put into the collection, and I cannot initiate an instance of the real class because I cannot reference Project.Business from Project.Data, argh!
The interfaces seemed to be an OK method, until I reached that point.
Previously to the nightmare with architectures im currently experiencing, id just have a Customer object, which would encapsulate everything to do with the Customer, including data access. So effectively my business and data layers would be combined. Im thinking of going back to this, although I like the idea of seperation.
I notice that alot of people pass DataSet's and SqlDataReaders between layers, I don't like the DataSet method because its messy, and isn't good for passing a single value, and SqlDataReaders hold the connection until closed - which is obviously not the best thing to do. So I was considering passing XML between layers - what with standards and everything I thought this would be good, but i've been advised that this causes a big performance overhead.
So what am I to do? Can anyone please shed some light on my architecture problems before I go mad
I look forward to any responses,
Thanks,
Matt.
What's the standard practice for implementing a 3 tier architecture with asp.net? i've tried to seperate my business and data layers, but im struggling with the communication between layers - since I can't pass the business object by ref to the data layer because that causes a circular reference between the libraries.
So I tried creating another library of interfaces, so:
Project.Business references Project.Business.Interfaces, Project.Data
and
Project.Data references Project.Interfaces
then
Project (presentation) references Project.Business
This did the trick to a point, but im now encountering problems with it, for instance take the following method:
Code:
// Project.Data.GetCustomers();
public static ICustomerCollection GetCustomers(ref ICustomerCollection customers, int storeID)
{
// data stuff
while(reader.Read())
{
ICustomer customer = ????
customer.CustomerID = (int) reader["CustomerID"];
// And so on
customers.Add(customer); }
}
The problem there is that I cannot initiate a instance of an interface to put into the collection, and I cannot initiate an instance of the real class because I cannot reference Project.Business from Project.Data, argh!
The interfaces seemed to be an OK method, until I reached that point.
Previously to the nightmare with architectures im currently experiencing, id just have a Customer object, which would encapsulate everything to do with the Customer, including data access. So effectively my business and data layers would be combined. Im thinking of going back to this, although I like the idea of seperation.
I notice that alot of people pass DataSet's and SqlDataReaders between layers, I don't like the DataSet method because its messy, and isn't good for passing a single value, and SqlDataReaders hold the connection until closed - which is obviously not the best thing to do. So I was considering passing XML between layers - what with standards and everything I thought this would be good, but i've been advised that this causes a big performance overhead.
So what am I to do? Can anyone please shed some light on my architecture problems before I go mad
I look forward to any responses,
Thanks,
Matt.