473,385 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

BLL & DAL: How are they different?

First, just in case, BLL = Business Logic Layer and DAL = Data Access
Layer.

I guess this is really a question about architecture. I believe there
are many architect here.

Software architecture is sorta new to me. I searched a little and did
find this:

http://www.velocityreviews.com/forum...l-and-dal.html

It helped me understand a little bit about their differences and the
advantages of separating them. And now I do have one simple
question:

How do I know what needs to go to the BLL and what needs to go to the
DAL?

My guess is this: Any method that needs to do something like
connection.Open() and use a Sql command (including stored procedure)
should go into the DAL, right? Or is this a principle too naive in
software architecture?

Thanks for sharing your insights into this question.
Jan 28 '08 #1
11 9430
"gnewsgroup" <gn********@gmail.comwrote in message
news:b3**********************************@e23g2000 prf.googlegroups.com...
First, just in case, BLL = Business Logic Layer and DAL = Data Access
Layer.

I guess this is really a question about architecture. I believe there
are many architect here.

Software architecture is sorta new to me. I searched a little and did
find this:

http://www.velocityreviews.com/forum...l-and-dal.html

It helped me understand a little bit about their differences and the
advantages of separating them. And now I do have one simple
question:

How do I know what needs to go to the BLL and what needs to go to the
DAL?

My guess is this: Any method that needs to do something like
connection.Open() and use a Sql command (including stored procedure)
should go into the DAL, right? Or is this a principle too naive in
software architecture?
Not really, though stored procedures won't be in the DAL because they are
RDBMS objects...

Here's an easy (though perhaps over-simplistic) way to think of it.

Project A, Project B and Project C are all totally different, but they all
use SQL Server as their RDBMS. Therefore, they will all have different BLL
but can share the same DAL.

Project D, on the other hand, supports multiple RDBMS. Therefore, it might
have the same DAL as the Projects A, B & C, plus additional DALs which
support Oracle, MySQL, Postgre etc. Alternatively, it may have a single DAL
which supports multiple backend RDBMS through a factory pattern.

Essentially, the BLL and DAL should be completely independent to the extent
that you are able to change one of them without needing to change the
other...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jan 28 '08 #2
On Jan 28, 9:39 am, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
"gnewsgroup" <gnewsgr...@gmail.comwrote in message

news:b3**********************************@e23g2000 prf.googlegroups.com...
First, just in case, BLL = Business Logic Layer and DAL = Data Access
Layer.
I guess this is really a question about architecture. I believe there
are many architect here.
Software architecture is sorta new to me. I searched a little and did
find this:
http://www.velocityreviews.com/forum...l-and-dal.html
It helped me understand a little bit about their differences and the
advantages of separating them. And now I do have one simple
question:
How do I know what needs to go to the BLL and what needs to go to the
DAL?
My guess is this: Any method that needs to do something like
connection.Open() and use a Sql command (including stored procedure)
should go into the DAL, right? Or is this a principle too naive in
software architecture?

Not really, though stored procedures won't be in the DAL because they are
RDBMS objects...

Here's an easy (though perhaps over-simplistic) way to think of it.

Project A, Project B and Project C are all totally different, but they all
use SQL Server as their RDBMS. Therefore, they will all have different BLL
but can share the same DAL.

Project D, on the other hand, supports multiple RDBMS. Therefore, it might
have the same DAL as the Projects A, B & C, plus additional DALs which
support Oracle, MySQL, Postgre etc. Alternatively, it may have a single DAL
which supports multiple backend RDBMS through a factory pattern.

Essentially, the BLL and DAL should be completely independent to the extent
that you are able to change one of them without needing to change the
other...

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
On Jan 28, 9:39 am, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
"gnewsgroup" <gnewsgr...@gmail.comwrote in message

news:b3**********************************@e23g2000 prf.googlegroups.com...
First, just in case, BLL = Business Logic Layer and DAL = Data Access
Layer.
I guess this is really a question about architecture. I believe there
are many architect here.
Software architecture is sorta new to me. I searched a little and did
find this:
http://www.velocityreviews.com/forum...l-and-dal.html
It helped me understand a little bit about their differences and the
advantages of separating them. And now I do have one simple
question:
How do I know what needs to go to the BLL and what needs to go to the
DAL?
My guess is this: Any method that needs to do something like
connection.Open() and use a Sql command (including stored procedure)
should go into the DAL, right? Or is this a principle too naive in
software architecture?

Not really, though stored procedures won't be in the DAL because they are
RDBMS objects...

Here's an easy (though perhaps over-simplistic) way to think of it.

Project A, Project B and Project C are all totally different, but they all
use SQL Server as their RDBMS. Therefore, they will all have different BLL
but can share the same DAL.

Project D, on the other hand, supports multiple RDBMS. Therefore, it might
have the same DAL as the Projects A, B & C, plus additional DALs which
support Oracle, MySQL, Postgre etc. Alternatively, it may have a single DAL
which supports multiple backend RDBMS through a factory pattern.

Essentially, the BLL and DAL should be completely independent to the extent
that you are able to change one of them without needing to change the
other...

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
Thank you. I understand that there are a lot of advantages of
separating them. But I am still not sure what goes into the BLL, and
what goes into the DAL. Sounds like both layers can *rightfully*
access the database? Any hint? Thanks.
Jan 28 '08 #3
See:

http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!139.entry
I have a 2.0 version of the blog entry/code as well.

http://sholliday.spaces.live.com/Blog/
My rule of thumb is that the DAL returns:
1. DataSets
2. IDataReaders
3. Scalars
4. Voids/Nothings

You can read the why at the blog.

PS
Read the "bird's eye" view MS article I provide a URL to as well.


"gnewsgroup" <gn********@gmail.comwrote in message
news:b3**********************************@e23g2000 prf.googlegroups.com...
First, just in case, BLL = Business Logic Layer and DAL = Data Access
Layer.

I guess this is really a question about architecture. I believe there
are many architect here.

Software architecture is sorta new to me. I searched a little and did
find this:

http://www.velocityreviews.com/forum...l-and-dal.html

It helped me understand a little bit about their differences and the
advantages of separating them. And now I do have one simple
question:

How do I know what needs to go to the BLL and what needs to go to the
DAL?

My guess is this: Any method that needs to do something like
connection.Open() and use a Sql command (including stored procedure)
should go into the DAL, right? Or is this a principle too naive in
software architecture?

Thanks for sharing your insights into this question.

Jan 28 '08 #4
"gnewsgroup" <gn********@gmail.comwrote in message
news:f4**********************************@q21g2000 hsa.googlegroups.com...
Thank you. I understand that there are a lot of advantages of
separating them. But I am still not sure what goes into the BLL, and
what goes into the DAL. Sounds like both layers can *rightfully*
access the database?
Absolutely not! Only the DAL should access the RDBMS. If the BLL requires
interaction with the RDBMS, it uses the DAL...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jan 28 '08 #5
//
Sounds like both layers can *rightfully*
access the database? //

In my opinion:

NO.
The DAL talks to the DB.

The BAL talks to the DAL. Using the 4 things I mention at my blog (the
"returns" from the DAL), you can get what you need done.
And you're safe if you ever need to change RDBMS's.


"gnewsgroup" <gn********@gmail.comwrote in message
news:f4**********************************@q21g2000 hsa.googlegroups.com...
On Jan 28, 9:39 am, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
>"gnewsgroup" <gnewsgr...@gmail.comwrote in message

news:b3**********************************@e23g200 0prf.googlegroups.com...
First, just in case, BLL = Business Logic Layer and DAL = Data Access
Layer.
I guess this is really a question about architecture. I believe there
are many architect here.
Software architecture is sorta new to me. I searched a little and did
find this:
>http://www.velocityreviews.com/forum...l-and-dal.html
It helped me understand a little bit about their differences and the
advantages of separating them. And now I do have one simple
question:
How do I know what needs to go to the BLL and what needs to go to the
DAL?
My guess is this: Any method that needs to do something like
connection.Open() and use a Sql command (including stored procedure)
should go into the DAL, right? Or is this a principle too naive in
software architecture?

Not really, though stored procedures won't be in the DAL because they are
RDBMS objects...

Here's an easy (though perhaps over-simplistic) way to think of it.

Project A, Project B and Project C are all totally different, but they
all
use SQL Server as their RDBMS. Therefore, they will all have different
BLL
but can share the same DAL.

Project D, on the other hand, supports multiple RDBMS. Therefore, it
might
have the same DAL as the Projects A, B & C, plus additional DALs which
support Oracle, MySQL, Postgre etc. Alternatively, it may have a single
DAL
which supports multiple backend RDBMS through a factory pattern.

Essentially, the BLL and DAL should be completely independent to the
extent
that you are able to change one of them without needing to change the
other...

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net

On Jan 28, 9:39 am, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
>"gnewsgroup" <gnewsgr...@gmail.comwrote in message

news:b3**********************************@e23g200 0prf.googlegroups.com...
First, just in case, BLL = Business Logic Layer and DAL = Data Access
Layer.
I guess this is really a question about architecture. I believe there
are many architect here.
Software architecture is sorta new to me. I searched a little and did
find this:
>http://www.velocityreviews.com/forum...l-and-dal.html
It helped me understand a little bit about their differences and the
advantages of separating them. And now I do have one simple
question:
How do I know what needs to go to the BLL and what needs to go to the
DAL?
My guess is this: Any method that needs to do something like
connection.Open() and use a Sql command (including stored procedure)
should go into the DAL, right? Or is this a principle too naive in
software architecture?

Not really, though stored procedures won't be in the DAL because they are
RDBMS objects...

Here's an easy (though perhaps over-simplistic) way to think of it.

Project A, Project B and Project C are all totally different, but they
all
use SQL Server as their RDBMS. Therefore, they will all have different
BLL
but can share the same DAL.

Project D, on the other hand, supports multiple RDBMS. Therefore, it
might
have the same DAL as the Projects A, B & C, plus additional DALs which
support Oracle, MySQL, Postgre etc. Alternatively, it may have a single
DAL
which supports multiple backend RDBMS through a factory pattern.

Essentially, the BLL and DAL should be completely independent to the
extent
that you are able to change one of them without needing to change the
other...

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net

Thank you. I understand that there are a lot of advantages of
separating them. But I am still not sure what goes into the BLL, and
what goes into the DAL. Sounds like both layers can *rightfully*
access the database? Any hint? Thanks.

Jan 28 '08 #6
On Jan 28, 10:24 am, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
"gnewsgroup" <gnewsgr...@gmail.comwrote in message

news:f4**********************************@q21g2000 hsa.googlegroups.com...
Thank you. I understand that there are a lot of advantages of
separating them. But I am still not sure what goes into the BLL, and
what goes into the DAL. Sounds like both layers can *rightfully*
access the database?

Absolutely not! Only the DAL should access the RDBMS. If the BLL requires
interaction with the RDBMS, it uses the DAL...

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
Fantastic, that sorta demystifies my confusion. Then, I have actually
been intuitively separating them in my web application. I've put most
methods that return DataTable, SqlDataReader, DataSet and those that
do insert, delete, update under App_Code.

Next question: Are event handlers considered in the presentation
layer? Should the code-behind file contain only event handlers and
everything else should go to either the BLL or DAL?

Thanks again.
Jan 28 '08 #7
"Scott Roberts" <sr******@no.spam.here-webworks-software.comwrote in
message news:e4**************@TK2MSFTNGP02.phx.gbl...
What have you really gained here? The ability to swap out SqlClient for
OracleClient? I guess that's nice, but IMO doesn't go far enough.
Like I said in my first reply, this is a very simplistic explanation of BLL
and DAL...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jan 28 '08 #8
<zh****@gmail.comwrote in message
news:d6**********************************@1g2000hs l.googlegroups.com...
Question: I suppose colParamaters should always be an array of string,
such that when we add more parameters to a stored procedure in the
RDBMS, we don't have to modify the code in the DAL, right?
Depends on the RDBMS but, for SQL Server, I use the SqlParameters
collection:
http://www.google.co.uk/search?sourc...=SqlParameters
BTW, do DAL mostly have static methods?
Depends... The Microsoft DAAB does, and mine does because I based it on the
Microsoft one...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jan 28 '08 #9
<ch*******@yahoo.comwrote in message
news:de**********************************@e6g2000p rf.googlegroups.com...
The DAL is usually a wrapper for the stored procedures used in
accessing data from the database. (That is if you are a stored proc
person).
And what if you aren't a stored procedure person...?
Your DAL might look like this:
public static DataTable GetStockDetails(DbTransaction tran, object SD_SRN)
That's precisely what your DAL *shouldn't* look like!

The DAL should not contain any reference to specific business logic, in this
case stock details.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jan 29 '08 #10
>There is still a relatively tight coupling between the BLL and the RDBMS
>(even though there is a DAL in the middle). The only way to mitigate this
"problem" is with a DAL mapping scheme (or, my preference, an Object
Persistence Framework). Of course, this adds untold complexity to the DAL
and should not be embarked upon lightly. However, there are several 3rd
party DALs out there that do precisely this, and I hold out hope that
LinqToSql will be another viable option.

Thanks for making it clearer. When I said "I got an idea", I was
thinking to myself "Oh, so the BLL isn't really independent from the
Data layer at least." Exactly like what you said, there is still a
coupling btwn the BLL and the RDBMS.
Well, the only way to completely avoid coupling the BLL and RDBMS is to make
your RDBMS so generic that it is essentially useless outside of your
application. I've considered doing just that in the past, but it seems a bit
extreme and I admit, I like to peek directly into the DB. Not to mention
that most reporting tools utilize direct DB access as well.

So there is almost always *some* coupling. The question is, how much? I
guess that ultimately depends on your situation.

Jan 29 '08 #11
"Chris Shepherd" <ch**@nospam.chsh.cawrote in message
news:Om**************@TK2MSFTNGP02.phx.gbl...
How do you manage shifts between database servers or even other storage
mediums (webservices, etc.) with this though?
Factory pattern...
IMO this is contrary to the purpose of abstraction as you are placing Data
Access implementation details inside your BLL.
My BLL interfaces with my DAL, never directly with the RDBMS...
It's great if you only have one place in your BLL where that data is
accessed,
??? My BLL interfaces with my DAL all over the place - everywhere it needs
to, in fact...
but what about cases where you need a different solution to retrieve your
data
Factory pattern...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jan 29 '08 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Brian Staff | last post by:
I was recently on a OO Design course<g> and as a result I've decided to "Tier" my ASP classic pages for maintainability. Browser <----> PT <---> BT <---> DT PT == Presentation Tier BT ==...
7
by: Steve | last post by:
Hi all, I'm designing my DAL layer(s) for our suite of applications and I'm designing myself in circles, it's gotten to the point where each idea just mixes me up more :) We have 3 loosely...
6
by: dm1608 | last post by:
I'm relatively new to ASP.NET 2.0 and am struggling with trying to find the best naming convention for the BAL and DAL objects within my database. Does anyone have any recommendations or best...
10
by: Roy | last post by:
Recently I've been trying to convert over my sqldatasource's to objectdatasource's to take advantage of the custom paging functionality of objectdatasource's. These attempts have plunged me...
1
by: den 2005 | last post by:
Hi everybody, I created several stored procedure in a local sql server 2005 express database, now when I call/execute them in the asp.net 2.0 web page, it returns an error message of "Cannot...
10
by: Fred Mertz | last post by:
I'm wondering what some of the important considerations are regarding implementing the DAL as a static class vs creating instances of it as needed. I'm writing a .NET 2.0 Windows application...
13
by: Jeff | last post by:
Hey ASP.NET 2.0 I'm designing the DAL (Data Access Layer) of my web application. I want every table to have a strongly typed object as wrapper arround the table. So that for example if the...
30
by: Cramer | last post by:
I've finally gotton board with TDD (test driven development) and wow is it effective! I went from sceptic to True Believer with my first effort. My question: According to the various books and...
1
by: No Name | last post by:
Hello, I have one BLL object X with method Y. Inside method Y (*) I call DAL object(s). Operation Y can include more then one DAL object (dalObj1.Write, dalObj2.Write) so I create some kind...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.