Subject: Seperating Layers
Posted By: rodmcleay Post Date: 8/15/2006 2:30:22 AM
Hi all,
I am just trying to impliment this archetecture in my own site.
I dont quite understand how to seperate these layers.
How does the DAL gain access to its providers stipulated in the Design Tier Config file???
Many Thanks.
Rod

======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
Reply By: englere Reply Date: 8/15/2006 11:27:47 PM
Just search for the key in the code to see how he's using it.

Frankly I'm not a firm believer in using plugable DBMS providers unless you are serious about supporting more than 1 kind of DBMS. But then all of your SQL needs to be portable, or else you need several sets of SQL. All of this is ugly and adds nothing useful if you know you'll always be using SQL Server.

Don't confuse separation-of-tiers with the concept of a pluggable provider. The DBMS provider issue only affects the DAL. Ideally the higher tiers wouldn't need to know which DBMS you're using. But the would of databases isn't exactly ideal. Consider SQL paging for example: your business tier has to know how this is going to work so it requires knowledge of the DBMS.

Eric

Reply By: rodmcleay Reply Date: 8/15/2006 11:42:00 PM
Hi Englere,
Thanks for your reply.
This is a bit of a excersize for me at the moment, so Im not too concerned about the practise of changing DB's.
Although I do whish to make an app that I would expect to install in different environments within the same industry.
So I expect that they will all have the same type of data on hand somehwere, but in differing structures and db's.

My real concern was that I could not access the Config file from the seperated BLL as it is part of hte design layer.
I have since worked out that I can but I must specify that it is a Web App, which is not ideal for me.
I want to be able to save a "Person" record from the BLL and have any GUI impliment that Person object.

Am I correct that I would have to write a differing BLL depending on the GUI used?
How can I abstract the GUI so that I can reuse all my BL.

======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
Reply By: englere Reply Date: 8/17/2006 11:38:19 PM
You need to go with an Interface-based design if you really want DBMS independence. I'm still not sure if you understand how hard it is to support multiple options like SQL Server and Oracle, but if your needs are trivial you can use the OleDbProvider.

If your needs are advanced you are going to wish you never went down that road. I use both SQL Server and Oracle and I can't tell you how hard it is to keep the SQL performant, and also portable. You really end up duplicating your SQL so it can be tuned independently. The idea of "one size fits all" SQL is definitely not workable unless your needs are very basic.

There are many ways to specify a provider. If you were desparate you could even do it in machine.config, since that's available to all .NET classes on the computer.

Or checkout the Configuration application block that's part of the Enterprise Library. By the way, you'll learn a ton by studying the source code of that library.

Eric

Reply By: rodmcleay Reply Date: 8/18/2006 1:05:05 AM
Thanks Englere.
I'll take another look at my needs for the database.
So I can use machine.config for a web app?????


======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
Reply By: englere Reply Date: 8/21/2006 10:38:57 AM
You can use machine.config for any kind of .net application, including class libraries. But you can also use any config file of your choice (you can easily load an .xml file yourself), or the registry. I don't care much for the registry because of deployment difficulties.

Hosted websites won't give you access to machine.config or the registry, so you'd need to use your own config file in that case.

I made a singleton configuration class for my company that prevents it from being loaded more than once per app domain - this is a performance boosting benefit. I also added support for encrypting/decrypting sensitive values.

Be advised that if you use your own xml file you should treat it entirely as readonly to avoid any threading problems. Or else you can write your own code to do thread locking if you need to write to it from an application that might have multiple users writing at the same time.

You can read more about Singleton here - I strongly recommend option 5:
http://www.yoda.arachsys.com/csharp/singleton.html

Eric


Go to topic 48410

Return to index page 198
Return to index page 197
Return to index page 196
Return to index page 195
Return to index page 194
Return to index page 193
Return to index page 192
Return to index page 191
Return to index page 190
Return to index page 189