Solved

How to construct DAL & BLL?!?!?

Posted on 2009-05-16
5
1,260 Views
Last Modified: 2013-11-12
OK, I have had it!

How do you design DAL & BLL?!??!?? For love sakes!

Do you have methods like Open(), Close(), ExecuteScalar(string spName), ExecuteReader(string spName, DbParameter[] parameters), CreateParameter() etc. !??!?!?!?!??!?!?!?!?!!?!?!!??!?!?!?!?!?!?!?

Or do you have your entire logic in the DAL and just call the methods in the DAL class from the BLL class... with the exact same name as they appear in the DAL... just aliasing them... !?!!??!?!?

Do you have a class per entity???

How do you make them generic???

Do you have methods like GetEmpleyeeByID(string empID) in your BLL!?????!???

Or do you have methods like GetEntities().. ?!???

Do you open the connection directly for each method from the DAL...?? Or do you reveal the Open(), Close().. for the BLL to use!?

Do you use Try...Catch...Finally statements right on the DAL methods?? Or do you use them in the BLL??? Or do you even use them in the PL(UI)???

Some say this... some say this... and some say "use the wizards..." - I do not want use the wizards!!


So how the **** do you write DAL & BLL properly...
which can later on be used for other projects!?
0
Comment
Question by:zooz111
  • 2
  • 2
5 Comments
 
LVL 4

Assisted Solution

by:TMarkham1
TMarkham1 earned 20 total points
ID: 24405305
You're going to love this answer...

It depends.

The reason "some say this"... and "some say that" is because this area isn't really a "one size fits all" kind of entity. I've worked for many companies who each had different requirements regarding data access layer and business logic layer design. Incidentally, none of these companies got it "perfect" in my honest opinion... but they all worked well enough.

One methodology I personally like is this one from Paul D. Sheriff and Associates on the Fundamentals of N-Tier Architecture, which includes the data access layer and business logic layers. This isn't the method I employed at any of my jobs however... I just thought it looked like a good way of doing it. This is an e-book and it costs about $20.

http://www.pdsa.com/Products/ProductDetail.aspx?prod=51

0
 

Author Comment

by:zooz111
ID: 24406868
Thank you for your answer!

I'll take a look at that book.
0
 
LVL 18

Accepted Solution

by:
DarrenD earned 30 total points
ID: 24441358
Hi,

I've tried to answer your question as best I can. But I think that you should decide what type of architecture you wish to use...

What are you going for? These are just three that you could use...
Client -> BLL/DAL -> Database
Client -> BLL -> DAL -> Database
Client -> BLL -> Entities -> DAL -> Database

How do you design DAL & BLL?!??!?? For love sakes!
You can put the DAL and BLL into the same DLL or you can have the DAL as a seperate DLL only performing the actual database operations no mater what table you are wishing to update. Then you can have DataEntities which are classes that represent the actual tables. These contain the CRUD operations and use the DAL to simply exectute the SQL SP. The BLL can use one or many of the DataEntities in order to perform some operation and return a either a new class that is a mixture of the other Entities or just an Entity.

Do you have methods like Open(), Close(), ExecuteScalar(string spName), ExecuteReader(string spName, DbParameter[] parameters), CreateParameter() etc. !??!?!?!?!??!?!?!?!?!!?!?!!??!?!?!?!?!?!?!? Yes. You can create an interface for a DAL and place the method names mentioned above it the interface as methods. Then simply implement the interface for whatever database you are connecting to.

Or do you have your entire logic in the DAL and just call the methods in the DAL class from the BLL class... with the exact same name as they appear in the DAL... just aliasing them... !?!!??!?!? Not sure what you mean here.

Do you have a class per entity??? Entity class per table? Yes

How do you make them generic??? Don't know what you mean. Don't think you can make the entity class generic

Do you have methods like GetEmpleyeeByID(string empID) in your BLL!?????!??? Yes, I would CALL GetEmpleyeeByID(string empID) from the BLL but the actual method would be in the EmployeeEntity class which is a copy of the structure of the database table Employee.

Or do you have methods like GetEntities().. ?!??? In the Entity classes I would have GetEntities() and GetEtities(EntityId) etc... and then let the business layer validate and perform operations.

Do you open the connection directly for each method from the DAL...?? Or do you reveal the Open(), Close().. for the BLL to use!?
Only to BLL. Only create the DAL class when you need to read or write to the database and then close it immediately.

Do you use Try...Catch...Finally statements right on the DAL methods?? Or do you use them in the BLL??? Or do you even use them in the PL(UI)??? Yes, in order to catch any Server/Database specific errors it is a good idea to have try catch blocks around all methods in all layers and catch them in order to display a useful message to the user.

Hope this helps,

Darren
0
 
LVL 18

Expert Comment

by:DarrenD
ID: 24441381
Also,

You should decide if you want to code everything yourself as you could use Microsoft .NET application blocks for Data Access.

http://www.cyberforge.com/weblog/aniltj/articles/217.aspx
0
 

Author Comment

by:zooz111
ID: 24532285
Alright, thank you very much, DarrenD, for your answers.

>> "Or do you have your entire logic in the DAL and just call the methods in the DAL class from the BLL class... with the exact same name as they appear in the DAL... just aliasing them... !?!!??!?!? Not sure what you mean here."

What I meant was...
I've seen people using their BLL as a reference-only for the DAL (The name of the method appears the SAME as in the BLL, DAL, and the same name for the StoredProcedure...).
The only thing in their BLL is a reference to the same thing in the DAL.. and in the DAL sits the whole logic of the action.
And even sometimes people use "SqlHelper" classes... to do the actions... like ExecuteScalar for instance....
Then what good is their BLL then!? Right?
They say that their BLL is used for information checking.. data converting.. (before or after passing to the DAL....) which I hardly seen them do... It's mostly just a reference to the DAL...


A-n-y-w-a-y-s, here's my BLL & DAL if you'd like to take a look...
And maybe tell me what I'm doing wrong or right....
BLL.txt
DAL.txt
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

What is Waterfall Model? Waterfall model is the classic Software Development Life Cycle method practiced in software development process. As the name "waterfall" describes, this development is flowing downwards steadily like waterfall, i.e., procee…
Introduction Many of the most common information processing tasks require sorting data sets.  For example, you may want to find the largest or smallest value in a collection.  Or you may want to order the data set in numeric or alphabetical order. …
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now