Passing Business Object Between Dal And Bll

Welcome. Please Login, Register, Or Activate! 
type your username and password to login
Date: November 24, 2009, 06:21 AM
431630 members and 298653 Topics
Latest Member: abbyman
Nairaland [Nigerian Forum] Home Help Search Who is currently online? Login Register
Nairaland Forum  |  Technology  |  Programming  |  Passing Business Object Between Dal And Bll
Pages: (1) Go Down Send this topic Notify of replies
Author Topic: Passing Business Object Between Dal And Bll  (Read 2178 views)
Smart K. (m)
Passing Business Object Between Dal And Bll
« on: November 07, 2007, 01:49 PM »

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);
        }
    }


SampleSite (C#)
protected void Page_Load(object sender, EventArgs e)
    {
        BLL.Account acct = new BLL.Account();
        acct.AccountName = "Magaji";
        acct.AccountNumber = "12346578";
        acct.Balance = 123311123321;

        if (acct.Update()) this.TextBox1.Text = "Updated";
        else this.TextBox1.Text = "Failed";

    }

Please, never mind about language mixing. I also use it to relay that .NET solution can contain more language.

Please enjoy.

Good luck.


* myScreen.jpg (78.38 KB, 961x441 )
 My Software Development Journey  Convert Code From Php To Vb.net   Any Visual Basic (VB) Guru In The House?  Page 2
Pages: (1) Go Up Send Topic to Friend by E-mail Reply 


Sections: Autos/Cars (2) Jobs/Vacancies (2) (3) Career Talk Education General(2) Politics Romance Computers Phones Travel
Sports Fashion Health Religion Celebrities TV/Movies (2) Music/Radio (2) Books Webmasters Programming

Links: Page1 Page2 Page3 Page4 Page5 Page6 Page7 Page8 Page9 Page10

Nairaland is owned by Oluwaseun Osewa. See also: Nairalist Classified Ads
Nairaland Forum | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.