Prohibit access to data layer

M

milop

Hello.

We have an app with UI, Business, and Data Tiers.

How can we ensure that the DAL tier is accessed only from the BLL tier? The
idea is to prevent direct access to the DAL from the UI (asp.net pages in
our case).

Thanks in advance,

Mike
 
S

sloan

Well, this is one reason I put the layers into different assemblies.

So that the Presentation layers .... do NOT reference the DAL(assembly), and
thus you can't break the rules.

Are you asking because of security? Or because of just enforcing good
design.

If its just good design, break the code out into different assemblies.

And if someone adds a reference from the Pres to the DAL.dll, fire them.

...

See:
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!139.entry

Also look at the "bird's eye view" article I mention at that blog entry.
 
M

milop

Thanks for replying.

Yes, it's in its own assembly.

Aside from firing the person I was wondering if there was a way, in the DAL
code, to detect the "caller".
 
S

sloan

Assembly.GetExecutingAssembly().
Assembly.GetCallingAssembly Method


http://msdn.microsoft.com/en-us/library/system.reflection.assembly.getcallingassembly.aspx



You can play around with those...I don't know if they'll work, but its at
least a hint.


The best solution is to put together a standards document and make people
stick to it.
It takes at least 1 person with some authority in the organization to get it
to work.
If you have a bunch of knights at the round table, then FIRING (at least)
one of them is the best route.
I'm half joking and half serious.

...

Good luck.
 
M

milop

I figured you were half-serious.

I thought about looking at the call stack but your way looks cleaner. I'll
take a closer look at it.

Thanks again,

Mike
 
M

Mike Urquiola

Couldn't you put the business and DAL together and mark the DAL as internal?
Then only the business could create and use DAL objects.
 
A

Alvin Bruney [ASP.NET MVP]

I agree, very good idea.

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top