hi guys, in the past i had to struggle to get my solution organized so that i would not have troubles of maintenance. I came across a lot of models and methods but I was not really fully satisfied. Hoever, I decided to go for separation of layers of my solution into projects namely, myweb(the site), BLL (Business Logic Layer) and DAL (Data Access Layer).
However, I ran into problem passing data between BLL and DAL because there are times i need to pass complex data and I wanted to avoid passing unreasonable no of parameters. For instance, say i want to update a student data that has 60 fields through DAL from BLL, i needed to pass the 60 parameters to DAL from BLL. I guess this is not a best practice. Note that I could not pass BLL objects to DAL as this will result in circular reference.
So, I introduced another layer to my solution called PRL (Presentation Layer). This layer forms the base layer for the BLL and DAL and contains the basic abstract classes that I would pass between DAL and BLL. As a matter of separation principle I made sure that PRL objects do not contain any methods. I make BLL objects inherit from these objects and therefor can pass BLL objects to DAL without hassles. finito.
Here are my sample codes
PRL (VB) Public MustInherit Class Account Private _accountNumber As String Private _accountName As String Private _balance As Double
Public Property AccountNumber() As String Get Return _accountNumber End Get Set(ByVal value As String) _accountNumber = value End Set End Property Public Property AccountName() As String Get Return _accountName End Get Set(ByVal value As String) _accountName = value End Set End Property Public Property Balance() As Double Get Return _balance End Get Set(ByVal value As Double) _balance = value End Set End Property
End Class
DAL (VB) Public Class InsertAccount Public Function Update(ByVal account As Presenters.Account) As Boolean
'//call stored procedure or something and return success or otherwise Return True
End Function
End Class
BLL (C#) public class Account : Presenters.Account { public bool Update() { DAL.InsertAccount ia = new DAL.InsertAccount(); return ia.Update(this); } }