0

Hi I am new to aspectj and after several hours of browsing around the internet I came to know something about aspectj. And also I had one doubt is this similar to immediate window in visual studio as in the aspectj in which we doing manually checking joint points...In immediate window if we type any variable it returns its value in current method. Likewise, in aspectj we are declaring manually that after calling specified function and returing variable values inside that method using system.out.println(). Is that right? if it is wrong...correct me

user3797438
  • 405
  • 3
  • 6
  • 24
  • I am having trouble understanding the question, but if I understand correctly you are likening pointcuts to setting breakpoints and inspecting variables? – Leon Oct 07 '14 at 12:08
  • The behaviour does seem very similar, but debugging is not done using aspects. How familiar are you with AOP? http://en.wikipedia.org/wiki/Aspect-oriented_programming – Leon Oct 07 '14 at 12:12
  • I am learning it for some days...But I have one doubt why we go for AOP and can I debug a program using it – user3797438 Oct 07 '14 at 12:15
  • Debugging AOP is like debugging anything else in Java, breakpoints will still fire and you can even write units tests for it. AOP has very specific use cases though. Maybe you can change you question to include you use case – Leon Oct 07 '14 at 12:17
  • From ur point,what I understand is " AOP is manual way of using break points"..correct me if I am wrong – user3797438 Oct 07 '14 at 12:19
  • Can u tell me the specific use cases of AOP... – user3797438 Oct 07 '14 at 12:20
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/62592/discussion-between-leon-and-user3797438). – Leon Oct 07 '14 at 12:21

1 Answers1

1

From the wikipeida article: AOP is a programming paradigm that aims to increase modularity by allowing the separation of cross-cutting concerns

Think about caching.... that is a concern that cuts across other concerns, like reading from a datastore. You can create a point cut to cache values being written to datastore and one to read from cache when the datastore is being accessed. Here is a link to a question specifically about AOP use cases: AOP use cases?

If you want to use AOP to "watch" a variable, to short answer is you can't. Pointcuts can only be applied methods

Community
  • 1
  • 1
Leon
  • 12,013
  • 5
  • 36
  • 59