Exception Layer?

N

Nemisis

Hi everyone,

As i have said before i am new to the 3-tier architecture and so far, i
have wrote quite a bit for both my DAL and BLL. Now one thing i want
to sort out is exceptions.

Should i just create an exception class within each layer? That way
the BLL, will know about the DALExceptions, GUI with know about BLL
etc. Or is it better to create a full exception library and include
that within the DAL (this doesnt sound right, but thought i would ask).

Many people dont seem to agree, but i thought, for example, if i had a
company and i needed to check that data before saving it, this would be
code for the BLL? Say the companyName had to be entered, else i was
not going to allow for the company to be saved. Am i right?

I would think this because, if i were to create another DAL, for xml
instead of SQL, i do not want to re-write all the checks again in both
DALs.

Thanks
 
M

Michael Nemtsev

Hello Nemisis,


N> As i have said before i am new to the 3-tier architecture and so far,
N> i have wrote quite a bit for both my DAL and BLL. Now one thing i
N> want to sort out is exceptions.
N>
N> Should i just create an exception class within each layer? That way
N> the BLL, will know about the DALExceptions, GUI with know about BLL
N> etc. Or is it better to create a full exception library and include
N> that within the DAL (this doesnt sound right, but thought i would
N> ask).

Even if u create full exception library (there are some of them already
created, for example see on Microsoft Exception Blocks) you need to know
how to differ you exceptions to proper distinguish them. There is no significant
difference what u choose, it's up to you, but it must be flexible for future
extensibility.

You can use MS Exception Block for exception management and prolong exceptions
to the required level.

N> Many people dont seem to agree, but i thought, for example, if i had
N> a company and i needed to check that data before saving it, this
N> would be code for the BLL? Say the companyName had to be entered,
N> else i was not going to allow for the company to be saved. Am i
N> right?

You need to perform checks both on client and business layers, because it's
too waste and insecure to rely only on one layer's checks.

N> I would think this because, if i were to create another DAL, for xml
N> instead of SQL, i do not want to re-write all the checks again in
N> both DALs.

DAL shouldn't be responsible for you business domain, it only manage your
data -whatever u supply.

---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch
 

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