Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,553 members, 7,955,058 topics. Date: Saturday, 21 September 2024 at 03:40 PM |
Nairaland Forum / Science/Technology / Programming / Passing Business Object Between Dal And Bll (5402 Views)
A Beginners Guide To Object-oriented Programming (OOP) In PHP 5+ / Let's Learn Object Oriented PHP! / Criticism Of Object Oriented Programming (2) (3) (4)
(1) (Reply)
Passing Business Object Between Dal And Bll by SmartK1(m): 1:49pm On Nov 07, 2007 |
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.
|
(1) (Reply)
Online Shopping System In Php Documentation Help / Programming Langauges In Nigeria 2016: Whats Hot, Whats Not / I'm Leaving Nairaland But Not Without A Gift For ALL Programmers!
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 10 |