views:

373

answers:

2

Background

I have a component that provides certain CRM services - specificCRM. I have a specificCRMAdapter which implements my IGeneralCRM interface.

Another component generalCRM exposes CRM functionality through IGeneralCRM and uses Spring.Net to inject the specificCRMAdapter to provide such funtionality.

Question

I want to be able to catch an exception if the specificCRM component fails. Should I implement Spring.Net AOP Throws advice to accomplish this or am I over engineering the problem because all I need to do is merely catch the exception.

Are there any benefits one way or the other.

Thanks, Confused.

A: 

If you are already using Spring AOP.Net, and you don't need to stretch every bit of performance, I say use an advice - later you can use advices for other stuff, user the new advice to catch more exceptions and integrate everything nicely.

Otherwise, just catch the exception. You should have code for exceptions anyway, wether in advices or try/catch blocks.

Miguel Ping
A: 

It really depends on what you intend to do with the exception. AOP is awesome but leads to complex configuration and is often an overkill.

Where AOP shines is in its ability to provide logic for handling the same business crosscuts over multiple objects. In your case, you seem to imply that you are working on a single implementation, so I would say to simply try catch it for now.

If you think you could reuse the same logic within multiple methods and objects, then AOP is a better solution.