Decorator pattern for data layer component

  • Thread starter Thread starter Einar Høst
  • Start date Start date
E

Einar Høst

Hi,

I'm writing a data layer for an app my company is developing. I'm thinking
about wrapping up the basic data access object in two decorator objects: one
to provide error checking on parameters, and one to provide generic logging
of exceptions. Is that a good idea or not? It adds some indirection, but at
the same time the code becomes less cluttered. And the decor can even be
"peeled" off at a later time if considered superfluous.

Any thoughts?
 
Hi,

Looks like a good idea overall. However, as for checking parameters for
errors, will the decorator always know which values are valid and which are
not?
 
Hi,

Good question, I believe the answer is "no, not really". It will provide
rudimentary checking only, for instance for null references. There is bound
to be some additional checking in the inner object as well, definitely.
Still, I think it will help a bit.

Regards,
Einar

Dmitriy Lapshin said:
Hi,

Looks like a good idea overall. However, as for checking parameters for
errors, will the decorator always know which values are valid and which are
not?

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

Einar Høst said:
Hi,

I'm writing a data layer for an app my company is developing. I'm thinking
about wrapping up the basic data access object in two decorator objects: one
to provide error checking on parameters, and one to provide generic logging
of exceptions. Is that a good idea or not? It adds some indirection, but at
the same time the code becomes less cluttered. And the decor can even be
"peeled" off at a later time if considered superfluous.

Any thoughts?
 
Back
Top