wood burning stoves 2.0*
The moose likes Other Java Products and Servers and the fly likes Do we need AOP ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Other Java Products and Servers
Bookmark "Do we need AOP ?" Watch "Do we need AOP ?" New topic
Author

Do we need AOP ?

HS Thomas
Ranch Hand

Joined: May 15, 2002
Posts: 3404
Here is a snippet from an article by Martin Fowler -
(discovered in the Process Forum - Architecture and SDLC)
Who Needs An Architect
"My reservation of Aspect-Oriented Programming
is that we already have fairly
good techniques for separating aspects
of programs, and we don�t use them. I
don�t think the real problem will be
solved by making better techniques for
separating aspects. We don�t know what
should be the aspects that need separating,
and we don�t know when it is worth
separating them and when it is not."
What would your reply be ?
regards
[ September 17, 2003: Message edited by: HS Thomas ]
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Just to give some context, the post is available at http://www.coderanch.com/t/130278/Agile/Architecture-SDLC
I think everyone can have a different opinion, and thus provide a different answer to this question. One thing that is generally accepted is that software becomes more and more complex and that OO will not be able to go alone and provide support for solving this complexity. OO is very good at providing a view of the world in terms of objects that represent localizable concerns. The problem is that software is not only made of localizable artifacts. For instance, security is usually an aspect of software systems that is not easily localizable with traditional OO techniques. Just look at the JDK sources and you will see that lots of methods in java.lang invoke a check*() method before doing their job in order to see whether the caller has the permission to execute the method or not. This would better be encapsulated in some aspect that would contain all security-related code of the JDK, so that when a change in the security policies is needed, you just go there and do the change instead of remembering where the h**l you need to do all the necessary changes. You can be sure you will forget to perform some changes and your system will be broken.
So, AOP will NOT replace OOP but it will elegantly complement it. OOP will be responsible for dealing with localizable concerns (objects) and AOP will take care of modularizing all concerns that cut across several objects or components (security, transaction, etc). In my opinion, one reason why AspectJ is a superset of the Java language is because AOP does not aim at killing OOP but only at complementing it and making it better. So instead of reinventing the wheel, Gregor & Co just reused what Java offered and enhanced it with a couple constructs.
Now, you are free to use AOP or not, you should never be constrained to use it. I would say that AspectJ and AOP in general is useful as soon as a certain complexity threshold has been attained in the software system under development. Of course, it would be better to figure out whether this threshold will be attained or not before attempting to use AspectJ in a project. Personally, we have been using AspectJ since the beginning and now all our software rely on that and we don't regret our choice.
[ September 17, 2003: Message edited by: Valentin Crettaz ]

SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
HS Thomas
Ranch Hand

Joined: May 15, 2002
Posts: 3404
Well said , Valentin and also a great link you posted.
we already have fairly
good techniques for separating aspects
of programs, and we don�t use them

What are the fairly good techniques and why don't we use them is REALLY what I'd like to know.
Thanks in advance!
regards
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Since this is Ralph Johnson's opinion, I guess he is the best person to answer that. I don't really see what the "fairly good techniques for separating aspects of programs" are.
I would answer that question with another question (I know this is bad ): if those techniques are "fairly good" as he mentions why don't we use them already? Why did a whole bunch of people recognize the need for developing new techniques for separating "aspects" and created a whole community on Aspect-Oriented Software Development (AOSD)?
I do however agree with the fact that it is not easy to identify the aspects present in a system and also that we don't know exactly when it is good to separate them.
[ September 17, 2003: Message edited by: Valentin Crettaz ]
HS Thomas
Ranch Hand

Joined: May 15, 2002
Posts: 3404

I do however agree with the fact that it is not easy to identify the aspects present in a system and also that we don't know exactly when it is good to separate them.

You've just started my next question.
Should there be something added to *Refactoring* to extract separate concerns and make them aspects ? Is there any work in this area.
(Considering Martin Fowler seems against AOP , perhaps not!)
Or is it a super programmer guide's (architect's) territory rather than a programmers ?
regards
[ September 17, 2003: Message edited by: HS Thomas ]
HS Thomas
Ranch Hand

Joined: May 15, 2002
Posts: 3404

Why did a whole bunch of people recognize the need for developing new techniques for separating "aspects" and created a whole community on Aspect-Oriented Software Development (AOSD)?

Perhaps they are lemmings
(Ramnivas please note this graemlin usually means the poster is joking !)
No seriously, how would you convert a sceptic like Johnson to dealing with aspects ?
What sort of scenarios, rules can you use to show that here is where aspects could be beneficial in layman terms ?
(Valentin has made a good start!)

regards
[ September 17, 2003: Message edited by: HS Thomas ]
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Considering Martin Fowler seems against AOP , perhaps not!
Please note that the statement quoted in Martin's article comes from Ralph Johnson which does not imply that Martin is against AOP!
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8904

How many langauges support AOP ? Are there more than AspectJ?


Groovy
Bhushan Jawle
Ranch Hand

Joined: Nov 22, 2001
Posts: 249
AspectWerkz is another framework for AOP. I am a bit confused by your 1st question though. Does a language need to support AOP ?
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Yes, there are many implementations of AOP. You can check them out at http://www.aosd.net/technology/index.php
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8904

Originally posted by Bhushan Jawle:
AspectWerkz is another framework for AOP. I am a bit confused by your 1st question though. Does a language need to support AOP ?


From Ramnivas
AspectJ is an aspect-oriented programming language (that uses Java as the base language), much like Java is an object-oriented programming language.
HS Thomas
Ranch Hand

Joined: May 15, 2002
Posts: 3404

Please note that the statement quoted in Martin's article comes from Ralph Johnson which does not imply that Martin is against AOP!

Sorry Valentin. That was very badly phrased. I have searched the web and Martin Fowler is remarkably silent about AOP.

If refactoring is for OOP perhaps there should be an equivalent for discovering aspects in AOP - Crosscutting for AOP so it would be natural for the programmer to discover aspects ?
Perhaps Raminvas covers this in his book ?

regards
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Refactoring (the activity) is not for OOP. It (the activity) can be applied to practically any type of code from assembly to C++ and Perl. It's just that we need to learn a new set of refactorings (the subject) that lead to better structured aspect code.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
HS Thomas
Ranch Hand

Joined: May 15, 2002
Posts: 3404
Aaah!
So you could refactor to POJOs or AJOs (Aspect Java Objects )
Who'll be rewriting the refactoring book ? (And I've just bought that. )
Thanks for making that clear, Lasse.
In order to get answers one must exhibit a lack of knowledge.
regards
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8904

http://c2.com/cgi/wiki?WhatIsRefactoring
HS Thomas
Ranch Hand

Joined: May 15, 2002
Posts: 3404
Thanks Pradeep for the link but it didn't answer my question.
regards
Andre Mermegas
Ranch Hand

Joined: Jun 20, 2001
Posts: 158
I love Martin Fowler don't get me wrong he is a genius but think it should be pretty easy to figure out the basics of what should be an aspect and what shouldn't just follow good OOP design.
A Car class should have only code which relates to being a car and nothing else, anything else should be an aspect.
[ September 17, 2003: Message edited by: Andre Mermegas ]

--=( Andre Mermegas )=--
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Who'll be rewriting the refactoring book ?
Whoever has managed to gather proven AOP patterns and repeatable steps to follow... and who has enough balls to write a sequel for "The Bible."
And I've just bought that.
Don't worry, Refactoring will be Good Stuff for years to come
Ramnivas Laddad
Author
Ranch Hand

Joined: Jul 23, 2003
Posts: 62
Wow, woke up this morning and saw that there are already 17 replies. Great community!
Refactroring and AOP are not at odds. It is much easier to add aspects to a well-refactored code and aspects are a useful way to refactor (a crosscutting concern out of) an existing piece of code.
Traditional (OO) refactroring can take you only up to a point. Look at the logging example in http://www.coderanch.com/t/91659/java/week-book-give-away. The logger code is already refactored out (into standard logging toolkit) and no traditional technique can take _logger.logp(..) code out of each method in Account and Customer class. Chapter 10 of AspectJ in Action (available for free download) shows conventional code and AspectJ-based code to perform authorization. You will see that in conventional implementation, there is a lot of code, but not much left to refactor. AspectJ-based solution takes out all that code out of core module and put it in a reusable aspect.
-Ramnivas


Ramnivas Laddad
Author, AspectJ in Action (http://manning.com/laddad2)
Twitter: ramnivas
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8904

Can someone send me AOP tutorial link.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
I don't know The tutorial for AOP but here are a couple of pages full of links to AspectJ related papers and publications:
http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspectj-home/publications.html
http://www.parc.com/research/csl/projects/aspectj/default.html
I also bumbed into this AspectJ tutorial once.
HS Thomas
Ranch Hand

Joined: May 15, 2002
Posts: 3404
Yes we do. Need AOP that is.
regards
Bhushan Jawle
Ranch Hand

Joined: Nov 22, 2001
Posts: 249
Or you can try this tutorial
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
No seriously, how would you convert a sceptic like Johnson to dealing with aspects ? --HS Thomas
I have invited Ralph Johnson and Martin Fowler to participate in this discussion
[ September 18, 2003: Message edited by: Valentin Crettaz ]
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8904

I will invite Ralph Johnson and Martin Fowler to participate in this discussion

When are the coming here?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Do we need AOP ?
 
Similar Threads
How long does it usually take beginning java learners to be able to start their first full game?
Jar file not working
Wrote SCEA Beta Test Exam Today - Feedback on the Sun Certified Architect Exam Part 1
Herb: Things to watch out for?
Trouble adding JLabels to JLayeredPane