• Post Reply Bookmark Topic Watch Topic
  • New Topic

What is an Aspect  RSS feed

 
Robby Robson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok I get that AOP is about inversion of Control/ Dependacy Injection , but what is an ASpect itself

answer one of those questions you see on IQ test



an Aspect is to ___ as an Object is to a Class.



Object being a instance of a class that is
 
Ken Krebs
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Robby,

an Aspect is to ___ as an Object is to a Class.


There is no direct corollary. Object and Class are very specific things where an Aspect is a generic term for something that cuts across many Objects/Classes within an aplication. I like to think of AOP as Behavior Injection. It's kind of like multiple inheritance only much more flexible as it isn't static like a class hierarchy.

From Rod Johnson/Juergen Hoeller's book "J2EE Without EJB":
An aspect is a modularization of a crosscutting concern; the gathering of code that might otherwise have been scattered.

A concern is a particular issue, concept, or area of interest for an application...


I highly recommend this book. The AOP chapter alone is worth most of the price.
 
Edward Kenworthy
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well first off, an aspect is not about inversion of control / dependency injection. They're different things. Personally as a developer I care about ioc/di (I use Spring) but I don't care very much about Aspects: in Spring its an implementation detail of the framework eg it's the way the Spring framework implements declarative transaction management. Personally I dont care that it happens to use aspects to do the job all I care about is my declarative transactions.

So short answer: imo unless you're writing a framework like Spring you probably don't need aspects because aspects are by definition about cross-cutting concerns (like logging, security, transaction management) which are a framework's domain not an individual application's. Again personally I think aspects actually overcomplicate matters if you try to use them in a generic manner in your application: ie you use them to insert logging code. IOC/DI in this case is an alternative that gives me almost the same effect but in a much more transparent manner. Hence the reason I care about IOC/DI but, whilst I understand Aspects, I think they're completely irrelevant to me developing an application.

Hope my rambling helps a bit ;-)

Edward
[ January 05, 2005: Message edited by: Edward Kenworthy ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!