• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

This week book give away

 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please give a great big JavaRanch welcome to: Ramnivas Laddad, author of "AspectJ in Action".
This week we are giving away copies of this book to four lucky winners who participate in this forum.
So say hi and start asking your questions!
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome Ramnivas!
We'll see whether this book promotion gets my aspects going... (I have to admit I haven't put as much effort as I would've liked into learning what it's all about)
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ramnivas,
I am not as well read in Java and design developments as I should be and the "JavaRanch Book Promotion" was pretty much the first I had heard of AOD and AspectJ. Having been brought up on OOAD, I would appreciate it if you could either list the salient differences/similarities between AspectJ and the "traditional" way of creating objects, or (if you think that is too lazy ), suggest some articles to get me started.
Many Thanks,
Ant
[ September 16, 2003: Message edited by: Ant B ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ramnivas,
Welcome to the Ranch, from a fellow Manning author!
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ramnivas
 
Author
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Everybody,
I am very delighted to be here and discuss your AOP/AspectJ questions.
About Ant Burge's question:
Crosscutting concerns � requirement, design, or implementation that span multiple modules are abound in practice: logging, tracing, dynamic profiling, service-level agreement, policy enforcement, pooling, caching, concurrency control, security, transaction management, business rules, and so forth. Traditional implementation of these concerns requires you to fuse their implementation with the core concern of a module. For example, a simple Account class may incorporate some code to address all of the above concerns. With aspect-oriented programming, you can implement each of the concern in a separate module called aspect.
Consider logging concern as an example. Traditional implementation may look something like:

With AspectJ, you can keep you core classes oblivious of logging:

That�s it. You can put this aspect into any Java program, compile using AspectJ compiler, and start seeing log output generated (which will be the same as the output generated by traditional implementation).
Now imagine a typical project with 100s, if not 1000s of classes and imagine a typical project with many other crosscutting present in a system. AspectJ can make life vastly simple by separating each individual concerns away from core business logic. Please read sample chapters (http://www.manning.com/laddad).
-Ramnivas
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ramnivas,
I�m finished reading your book and its just great(advice for Javaranchers: buy it!). But a friend of mine asked me something that I really couldn�t answer. The question is about the fine-grained granularity about logging. For example, supose I have the following class:
public class {
public someMethod(String foo) {
String myVar = "java";
// do some stuff

//At this point I would like to know the value of myVar.
// How can I do this (with aspectj)?

// do some more stuff

}
}
The question is how aspectj can show the value of some private variables for some method, just for logging (to know if its value, in the middle of a computation, is right)?
Thank you,
Julio Cesar
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I doubt that you can define pointcuts in the middle of a method. Could someone confirm this?
 
Ramnivas Laddad
Author
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Julio Cesar,
Thanks for buying and reading my book.
Lasse is right. You cannot define a poincut to capture join points that modify a local variable. The reason for such constraint is (while perhaps useful for very fine grained logging) it can lead to unstable crosscutting. You can, however, access assignment or read-access to a instance and class data member inside a method as well as calls to other methods.
-Ramnivas
 
Ant Burge
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ramnivas,
thanks very much for the in depth answer: I was just expecting a link and a "go and work it out for yourself" type comment!
I can see now why you would want to use this over standard OOP. Time to get learning!
Thanks again,
Ant
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic