Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Exception handling done thru AOP

Paul,

There are certainly times where you want to separate out a concern even if it is only done in one place (i.e., to avoid tangling even if there is no scattering). For some concerns that have a real modular nature, that makes a lot of sense. My view is that logging and catching (exceptional!) exceptions are sufficiently low level operations, that they make sense to handle directly in some cases.

You could of course use techniques like calling empty "hook" methods to mark specific lines where you want to emit a log. For exception handling, I try to refactor code to have a clean structure, and to use exception types to avoid as much special-case exception handling as possible. But if I need to handle a specific condition in a specific case (e.g., a NumberFormatException if I'm parsing input), I generally will just catch it (rather than, say, devising a mechanism whereby an error handling aspect catches this and communicates it to the class that was doing the parsing).

Ron Bodkin
Chief Technology Officer
New Aspects of Software
o: (415) 824-4690
m: (415) 509-2895


> ------------Original Message------------
> From: "Paul Kusch" <belmondo_paul@xxxxxxxxxxx>
> To: aspectj-users@xxxxxxxxxxx
> Date: Wed, Aug-25-2004 6:41 PM
> Subject: Re: [aspectj-users] Exception handling done thru AOP
>
> Ron,
> 
> I thought that logging or exception handling itself is a crosscutting 
> concern in all cases and that the goal is to separate all 
> logging/excepting 
> handling code out from primary concern code even though it means to 
> create 
> aspect that is used just in one place in the application. But what I am 
> 
> reading is that the goal is more reuse and that it makes sense to 
> extract 
> only those parts of crosscutting concerns that are reused and save 
> lines of 
> code and eliminate duplication.
> 
> Actually this was the reason why I was not sure if AOP should be used 
> in all 
> cases. If I separate say all logging or exception handling I end up 
> with 
> nice and clean primary concern code but I have aspects that apply only 
> in 
> one place which means more lines of code than when inlined.
> 
> Paul
> 
> 
> >From: "Ron Bodkin" <rbodkin@xxxxxxxxxxxxxx>
> >Reply-To: aspectj-users@xxxxxxxxxxx
> >To: aspectj-users@xxxxxxxxxxx
> >Subject: Re: [aspectj-users] Exception handling done thru AOP
> >Date: Mon, 23 Aug 2004 10:25:33 +0200
> >
> >Paul,
> >
> >I often use AOP to handle exceptions and find it valuable. At the same 
> 
> >time, there are definitely some cases where exceptions and their 
> handling 
> >are *not* crosscutting, and it is helpfully to explicitly throw them 
> and to 
> >explicitly handle them in a method. There are also cases where you 
> might 
> >start with inline exception handling and then refactor into an aspect 
> as 
> >you realize there _is_ a common policy that can be captured.
> >
> >The moral here is to use aspects to modularize crosscutting concerns. 
> This 
> >is true for applying AOP for other concerns that are often 
> crosscutting but 
> >sometimes specialized (e.g., logging errors and tracing is natural but 
> 
> >sometimes logging is really tied to a specific line of code).
> >
> >Ron Bodkin
> >Chief Technology Officer
> >New Aspects of Software
> >o: (415) 824-4690
> >m: (415) 509-2895
> >
> >
> > > ------------Original Message------------
> > > From: "Paul Kusch" <belmondo_paul@xxxxxxxxxxx>
> > > To: aspectj-users@xxxxxxxxxxx
> > > Date: Fri, Aug-20-2004 3:16 PM
> > > Subject: [aspectj-users] Exception handling done thru AOP
> > >
> > > Hello,
> > >
> > > I was experimenting with AJ to extract exceptional flows and have 
> mixed
> > >
> > > feelings. Could you please share your experience? Do you have now
> > > applications without any catch statement in primary concern or are 
> you
> > > being
> > > selective where you use AOP and where you embed catch statements in
> > > primary
> > > concern code.
> > >
> > > Thank you,
> > > Paul
> > >
> > > _________________________________________________________________
> > > Get ready for school! Find articles, homework help and more in the 
> Back
> > > to
> > > School Guide! http://special.msn.com/network/04backtoschool.armx
> > >
> > > _______________________________________________
> > > aspectj-users mailing list
> > > aspectj-users@xxxxxxxxxxx
> > > http://dev.eclipse.org/mailman/listinfo/aspectj-users
> > >
> > >
> >
> >_______________________________________________
> >aspectj-users mailing list
> >aspectj-users@xxxxxxxxxxx
> >http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 
> _________________________________________________________________
> Is your PC infected? Get a FREE online computer virus scan from McAfee® 
> 
> Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 
> 



Back to the top