Aspect-Oriented Programming Considered Harmful
kupci writes "The 'x considered harmful' cry is a little overused, but there is a Forrester report that discusses some of the pro's and con's of Aspect-oriented Programming, and includes some interesting links. It is mainly based on papers from the University of Passau. It's worth it just for Clark's 'COME FROM' article." From the article: "Aspect-oriented programming (AOP) is intended to address common problems that object-oriented programming (OOP) doesn't address well, plus some problems that OOP itself created. However, AOP is a risky solution: It is a very generic mechanism for solving some very specific concerns and has been likened to a kind of "GOTO" statement for OOP. Like GOTO, it can cause more harm than good."
The only thing worse would be GOTO + OOP, which of course = C++
Google, of course, returns a ton of results for aspect-oriented programming. Does anybody have one in particular that they recommend?
I'm a fairly experienced coder, but I don't have any experience with AOP whatever. I don't even know what it is!
OtakuBooty.com: Smart, funny, sexy nerds.
You're on crack. AOP is not specific to Java -- I've seen it done with Python -- see this article for example. AOP can be used for great evil, but it can also be used for great good. When I first read up on it, my first reaction was "wow! This must be how God programs!" :)
Wikipedia linkage
In computing, the programming paradigm of aspect-oriented programming (AOP) centers on constructs called aspects, which treat concerns of objects, classes, or methods. The aim of AOP is to separate program code related to the main purposes of the application (its core concerns) from code related to secondary purposes (cross-cutting concerns).
For example, a telecommunications application might have a core concern of routing calls, while code for timing and billing those calls would crosscut the whole object hierarchy. AOP aims to separate the billing concerns from the core concern. It moves code not related to solving the domain problem from the business logic into a separate module. The application code no longer contains pieces of crosscutting concerns scattered across modules; instead, programmers maintain crosscutting concerns in aspects; this makes it easier to maintain both core and crosscutting concerns.
Any program has principled points (join points) where programmers can identify and modify the program semantics. In AOP, programmers specify join points using a language feature called a pointcut, and specify the behavior to join those points by using advice such as methods or functions. Some variants of AOP allow programmers to extend the types in the system. These features enable aspects to implement behavior for concerns that crosscut the core concern of the application.
who is going to shell out that cash for 5 pages?
"Powerful language constructs can be dangerous when misused"
Thank you for the wonderful advice and welcome to 1971!!
As for the GOTO comparison, it is disingenuous. The problem with GOTO is not that it is a flow control change, the problem is that it is an [i]unstructured[/i] flow control change. AOP is nothing if not structured, in fact its potential flaw lies in that the structures it represents can be so complicated the programmer can lose track. It's the absolute opposite of GOTO.
Really, I did read the article, but the headline is kind of discomforting. I mean, how is it harmful? If I were reading this headline while writing aspect-oriented code, should I stop immediately? I wouldn't want to die, you know. If I'm going to die, Slashdot, you need to let me know!
hello dear sirs my name is jamesh i are india (bihar) can u guide me install red had linux 9?
Useful technique, chemical, or product can be dangerous when misused! With this groundbreaking announcement, aspect-oriented programming joins up with jet planes, oxygen, razor blades, and almonds. Scientists urge all Americans to avoid anything that could, in any way, be harmful to anyone, and the government will begin production of mandatory Full Isolation Spheres (tm) within the week.
Breaking Into the Industry - A development log about starting a game studio.
GOTO + Functional Programming, which of course = Call with Current Continuation
At which point your head explodes
http://angryflower.com/aposter.html
The one-paragraph 'article' is just a tagline for a 250 dollar document. Quite dissapointing to read that lead in and find that I won't actually be aquiring any new information on the topic. :\
--- "End Of Line" - MCP
There's a new idea in field I am incapable of getting a job in that is gaining in popularity among people I wish cared about my opinions. Buzzword I am dissing is intended to address common problems that buzzword everyone likes doesn't address well, plus something into which I have no insight. However, buzzword I am dissing is a risky solution: Complaint which betrays my ignorance and has been likened to somthing everyone hates. attack by analogy. Buzzword I am dissing will find some uses among people I secretly envy, but for the needs of (me) typical application developers, language gurus would do better to write something I can understand. My paper is important, pay me $50/page to read it.
There IS a GOTO statement in C++, an OOP language.
So how can AOP be like GOTO for OOP when GOTO is already the GOTO for OOP?
LK
"Hi. This is my friend, Jack Shit, and you don't know him." - Lord Kano
The Clark link discusses 'COME FROM'.. which, after some analysis, is merely a change from imperative to declarative syntax... however lamely. :-)
XSLt programmers will feel a vague sense of familiarity..
-fooburger
At the risk of being modded troll, nuking my karma, being yelled at, laughed at, and otherwise folded, spindled, and mutilated, I'm gonna say it:
I like GOTOs. GOTO has it's place. Even in C++. Sorry all you purists, but there are times when it just plain works.
*runs and puts on Chinese wicker fighting suit and hides, trembling, behind a flame-retardant wall*
Nothing is inexplicable; only unexplained -Tom Baker, Doctor Who
Because OOP purists would mysteriously erupt in convulsive fits mixed with violent outbursts of anger resembling a sex crazed bigfoot/unicorn hybrid if you actually used a GOTO statement while writing OOP code.
Log.printLog("some message " + someObject.toString());
everywhere you want to log something. But with AOP you can used kleen operators (*, +, ?, etc) to add Log.printLog() to certain methods of certain objects. Aspects allow you to inject code into method call boundaries. But like all programming constructs it can be abused. This is because you might get an exception stack trace that indicates a specific method call has thrown an exception when the exception came from code inserted by an aspect. But other languages can be abused too (Perl anyone). So I think this type of critism of aspects says more about the critic than about the programming construct. I don't use C++ to implement logic evaluators (I would use Prolog or another logic or unification based language). Nor do I try to write OO code in LISP (despite the horrid OO extensions for LISP) because each language has it strengths and weaknesses. For each application choose the language that best suites the task.
On another note, I think these types of critisms are really from people who are afraid of learning new languages or skills. They have worked long and hard to get good at C (or Java or some other language) and don't want to have to learn another language. Well suck it up, there aren't many Fortran programmers anymore and if you want to keep working, you must keep learning new languages and skills. Not that you should jump on every bandwagon, but if I'm writing something that needs to be really, really fast I use C. If I'm writing something that needs to be maintainable forever and speed isn't that important I use Java. The best tool for the task.
"Those that start by burning books, will end by burning men."
'It's worth it'. Come on, how many people here read the article, let alone will pay $250 for it?
dominionrd.blogspot.com - Restaurants on
Two fifty to hear some twat tell you that a new technology is good, but only in the right circumstances used by trained people.
What bollocks.
Do any CIOs still buy this crap? Do the sensationalist headlines do the job and actually sell this bs? "AOP considered harmful"...be afraid...be very afraid!
I personally don't have a week go by when we don't find another great use for AOP...and we write financial apps...so that blows his 'frameworks only' theory out of the water.
But I suppose "AOP, useful sometimes in the right circumstances if you make sure you train your people on how to use it, not so useful in others" doesn't exactly sell those $250 a pop articles, does it Carl
Boring. The real hackers used 10 ? "FUCK YOU",
$249
Looks to me like the most harmful part of it is that it's patented, or at least parts of it are.
I always thought GOTO was good: 10 PRINT "BASIC PWNZ" 20 GOTO 10 30 REM HAHA SUCKERS!
All your Sybase are belong to us.
...that you can't read the article. I guess it's lucky the reviewer posted a link to a simalar paper - but annoying none the less.
AOP Geeks Healthier Than You Thought
There has been a lot of buzz and hype in the Java community about AOP in the recent years.
I, personally, agree that AOP shortcomings outweight its benefits at this time. AOP requires steep learning curve, makes debugging more difficult (can't easily use it with Java debuggers that are available), reduces code readability and, overall, does more harm than good.
Considering all the hype around AOP I'm sure it will prove itself in a couple of years as useful as EJBs now, i.e. hardly useful at all.
Couldn't you like plug a load of them together and make like a beowulf cluster of them.
threadeds blog
Oh, wait, don't RTFA... it's probably not worth the $250 ($50/page) price tag to you.
You insensitive clod!
Yeah, you really got your head around this one, slugger. AOP is definitely only for Java.
The Farewell Tour II
The bad thing about AOP is that it adds lots of side effects to function calls and can thus make the program very hard to reason about. This is completely orthogonal to (purely) functional programming that intends to remove side effects thus making it easier to reason about programs.
Functional programming: f(1) == f(1) always, with no other effects to "global state" etc.
Imperative programming without AOP: f(1) != f(1) necessarily at every point of the code, as the function can access globals. It can also change the global state, so its effect is more than returning its value; it can have side effets.
Imperative programming with AOP: Same as above, plus the side effects may happen somewhere unrelated to the definition of f itself.
The article, links and topic are ludicrous. Essentially crapflooding by the editors.
GOTO doesn't cause harm (or its syntax sugared grandchildren), it's the programmer who is not able to understand when to use it or not. Such programmers are a harm by themselves :-)
Perl Programmer for hire
I think they meant AOR is considered harmful.
To anybody with any kind of musical taste.
It just ended up on Slashdot by accident...
OP is not specific to Java -- I've seen it done with Python
And it was invented by Kizcales working in Common Lisp. For example, see this brief history.
Those [like the grandparent] who do not know history...
C:\>copy con autoexec.bat
@echo off
echo ^G^GSYSTEM ERROR
autoexec.bat
^Z
1 file(s) copied.
C:\>copy con t.bat
echo Fuck you.
t.bat
^Z
1 file(s) copied.
C:\>t.bat
I want a new world. I think this one is broken.
The absence of "goto myfunc(param);" makes implementing coroutines or tail calls un-necessarily hard when using C (or compiling to C). There is no valid reason for a very-low-level language to hide features available from assembler.
This article is part of an early FUD PR campaign by a large software company on the west coast, which fears the rise of CL among developers.
AOP can be used for great evil, but it can also be used for great good. When I first read up on it, my first reaction was "wow! This must be how God programs!" :)
And that explains why he created Humans...:)
The absence of "goto myfunc(param);" makes implementing coroutines or tail calls un-necessarily hard when using C (or compiling to C).
If your C compiler does not optimize obvious tail calls (e.g. return myfunc(param);), then your C compiler has a bug.
There is no valid reason for a very-low-level language to hide features available from assembler.
C is not a very low level language. You're thinking of C--.
Some people pay hookers to take cheese graters to their johnsons, so you are in good company.
You mean Microsoft?
What haskell infact lets you do with its IO monad is construct instructions for a separate IO interpreter (that is not pure) within the Haskell runtime. It is a kind of DSL (domain-specific language), a concept that is used a lot in Haskell programs.
Then what are the impure languages? Dial-up?
http://www.cs.toronto.edu/~yijun/OpenOME.html/inde x.html
"OpenOME, a goal-/agent-/aspect-oriented requirements engineering tool
The Organization Modelling Environment (OME) is a general, goal-oriented and/or agent-oriented modeling and analysis tool. It provides users with a graphical interface to develop models, and supports access to a powerful knowledge base that allows for sophisticated computer-aided analysis. This tool is intended to provide software developers with a clear link between the requirements, specification and architectural design phases of development. Attention is also being placed on this use of this tool in business process reengineering."
My neighbor is an Aspect Oriented Programmer!
What about my 3 year old?
Is he gonna come down with cancer?
Should I move?
Is there a list that shows where these people live?
Can they be tracked by satelites?
The big IT consultancies like Forrestor, Meta, gartner, etc are intellectually bankrupt. If you want an example, read the free article off of Forrestor's web page on IT metrics. It's absolutely worthless. Believe it not, it says that you should evaluate your IT department based on a balanced scorecard that is calculated by, among other things, the number of steering commitee meetings you have. Yes, you read that right, the more meetings the better your department is.
These consultancies ran out of ideas a long time ago, and are trying to turn IT ito some Six Sigma pseudo-science. It doesn't work, but idiots still buy into it because it sounds impressive.
Tristan Yates
"But with AOP you can used kleen operators (*, +, ?, etc) to add Log.printLog() to certain methods of certain objects. Aspects allow you to inject code into method call boundaries."
And what if I want to add log statement somewhere in the middle of the method? And with some arbitrary objects? Logging only method call boundaries is pretty much useless.
All AOP examples I've seen deal mostly with loggind and transactions maangement (again within method boundaries). That's a good testament, IMO, of how useful AOP is.
How do I get suckers^H^H^H^H^H^H^Hfolks to pay $250 for my 5 page speculations on computer science topics? Seriously. I'm an academic, and I write 20+ pages per month of this stuff for free. If I could get even 100 people to pay $50 per page each for it, that would be $100K per month: that's way more than I make in a year at my current job. Leaving aside the question of the price of my immortal soul, it doesn't sound like too bad a gig.
I started to list my qualifications, but got tired of typing. Suffice it to say that they're way more than that Forrester guy has. Let me know folks: if 100 of you pay me $50 per page each, I'll research pretty much whatever you want.
Is GOP*: Globals Oriented Programming.
*No relation to a certain political party. No, really.
You've attempted to assign C++ to a complex left-hand-side expression (GOTO+OOP). This is a classic blunder. What you probably meant was: "GOTO"+"OOP" == "C++".
In addition, you're overloading the use of strings to have orthogonal meanings, which is frowned upon. After all, using the standard string operator overloading, your left-hand-side "GOTO"+"OOP" is simply "GOTOOOP", which is clearly not equal to "C++" -- a good comment compiler would notify you that this expression always evaluates to false. A further refinement would be to introduce your own class and write the expression as:
LanguageFeature("GOTO")+LanguageFeature("OOP") == LanguageFeature("C++").
In the future, I hope slashdot will provide a better comment compiler that can automatically detect such simple mistakes.
The concepts behind AspectJ, TMO, are not bright. They break encapsulation, they are too ambitious and far from real-world understanding of programming concerns. All in all, they introduce too many problems.
TMHO,Aspect Oriented Programming should be different, and should be based on something much simpler, much more down-to-earth ideas and more consistent with real-world needs.
Today it is easily possible to do using Java Annotations, that will specify class member's affinity with an aspect, and thus provide:
A) a mechanism by which the compiler could limit access (errors & warnings) to members according to their affinity with a common aspect or aspects (common to it and its caller);
B) a programmer, using a proper IDE, can view a breakdown of his code according to aspects.
C) in runtime, the current aspect should be visible to the program thus extending the ability to: I) log, and trace errors; II) affect work-flow according to the aspect in action (that's an intense feature so im not too sure about that)
Doing more than the above, looks to be like an abuse of proper programming concepts.
The Annotation mechanism introduced in Java 5 is quite powerful and maybe already provide all that is needed for the job, including hierarchical arrangement of aspects (slash annotations), attributes, etc. Very little is needed in order to implement what i propose.
Maybe i'll propose is to the JCP. What'd ya think?
The PL community is doing a bunch [http://aosd.net/2005/index.php ] and making a lot of progress. At Aspects Day [NEU/Brown 2005] there was a great presentation about its merits. On the one hand, aspects seem to invalidate invariants. However, the verification enthusiasts out there are making significant progress [Verifying Aspect Advice Modularly, SIGSOFT ISFCS 2004] Another view of aspects is that they explicitly programmers to change the semantics of their code[credit another ugrad at my school]. That's a lot of power. Slashdot should have linked to something not costing $250, esp considering most of the real work in the field is publicly available. Finally, AspectJ is just a Java realization of AOP, and therefore not the full deal. Open your minds - if you're looking for the next step in languages, don't look at the existing ones known to be crippled.
Except what we know is that the core concern of a telecomunications application ~is~ the billing and timing of calls.
That's why you always get billed even if sometimes the call is dropped. Never the other way around.
Remember when this was leaked? Well here it is... See where we'd be without GOTOS? 10 GOTO 20 20 GOTO 30 30 GOTO 40 40 GOTO 50 50 GOTO 60
GOTO was declared harmful but it's functionality was needed so it has beed replaced by other kind of control flow statements, mainly procedure and function calls (that is methods in OOP).
That's more a matter of syntax than of semantic.
If a consensus emerges that the current syntax of AOP is harmful we'll probably get new languages with a way to either prevent or explicitly declare those side effects.
Does anybody know if there is any ongoing work in this area?
ol1++0!
So let me get this straight..
AOP basically means that when an object is created, or a method is called you wan't to run some code?
So if we tried to put this into a non-OOP example you would basically be calling something else whenever certain functions were called? Eg calling a 'save', 'load' or 'start' function would result in running the 'logging' function too?
But as I gather (and its pretty hard to find a simple explanation around here) the idea of AOP is that it allows you to do this without having to put any function calls in your code, ie it 'captures events'. So if for example you had to implement some security checks but you were worried that someone in your project would forget to put the 'if(secure)' lines into their modules you could rest assured that AOP would be on the case.
Then theres COME FROM which is basically an event handler that says 'when you get to this line/label in your code, come over here and run me.
I see no problem with this in a relatively high-level environment where the goal is to write less code and where so much crap is going on in the background anyway (dynamic this and managed that) that another overlay is just going to make things look simpler.
Isn't this however almost exactly the same as an interrupt?
This comment does not represent the views or opinions of the user.
All these arguments about different methodologies and techniques being harmful or not boil down to one thing:
"There are no good constructs, there are no bad constructs; a compiler in the hands of a bad programmer is a bad thing, a compiler in the hands of a good programmer is no threat to anyone - except the patent system."US$49.80 per page!!!
A 1000-pages book should cost US$498.00!!!
It's stupid book with the worth of heavy 10 oil-barrels.
Wait a moment ...
I will go to buy a cheap book (US$60) from www.amazon.com.
1) Everyone uses the same construct to ensure everything is freed properly on routine exit, 2) If you see an alloc not inside a try then you immediately check for a leak, 3) There are fewer stylistic clashes over how *abnormal* conditions are passed at a programmer level (error management needs to be consistent; reading other peoples code becomes easier). For *non-critical* projects I alloc everything at the top, have one try and free everything at the bottom so no nasty indenting (only works well if code you are using has a rule of avoiding throwing exceptions in constructors e.g. using initialiser function that can throw exception instead of doing everything in the constructor).
Happy moony
And since Aspect-Oriented programming is a patented technique, basically nobody can legally use it unless you're a personal friend of the inventor.
So, who really cares if its theoretically any good, when legally it is worthless?
I've been following AOP (cautiously) for some years now. Here's a few salient points for those who don't have $250 to splash out.
The underlying principle of AOP is about "separation of concerns", a term introduced by Dijkstra back in 1974. Separation of concerns is a Good Thing[tm], but there's more than one way to do it. It's a conceptual thing more than it is any one particular implementation technique.
Both structured and OO programming offer techniques that allow the hacker to more clearly separate concerns: by organising their code into subroutines, modules, objects, methods and so on. The problem with OOP is that real world problems don't always break down into a set of clearly defined, independant object classes. In some cases you can end up with a problem fragmented into so many small pieces that you can no longer see the wood for the trees.
AOP tries to address this by allowing you to identify those concerns that don't fit neatly into an object model. These "cross-cutting" concerns are typically things like logging, debugging and security that affect many of the objects in your system. If you decide to change the way logging is handled, for example, you don't want to have to go and edit every single object that generates logging information. But that's often what happens in OO based systems - you design your class hierarchy with Products, Customers, Orders and other real-world entities in mind and implement them as "black-boxes" with internal functionality neatly hidden away. That's fine when the functionality really is local to the object, but not when it relates to a system-wide aspect like logging, etc. These are the kind of undesirable artifacts that can arise from the decomposition of a problem into objects.
However, that's not to say that there aren't ways of achieving the good parts of AOP in a non-AOP language. Many Design Patterns are examples of separating concerns. The Model/View/Controller and Model/Visitor patterns come immediately to mind. Going back to the early logging example, we could implement this in AOP fashion in an OO language, by creating a "Logger" object which implements all the logging functionality. Just make sure all your other objects delegate to the logger for logging rather than trying to do it themselves. Now you have all your logging code in one place, and you just have to worry about how you're going to pass the logger object around so that all your other objects can call on it... (and this is often the start of the rest of the problems...)
So AOP-a-like can be done in OO languages, but most OO languages aren't really cut out for it - you have to code the magic manually if you want it. Hence the rise of AOP languages (usually just bolt-on syntax additions to existing languages) that make this process that little bit easier.
AOP in Java does smell a little like GOTO, IMHO. In brief, it uses "join points" to connect different aspects together (e.g. call this logging method just before calling that other method). One can certainly argue that it's a more structured form of GOTO, but I believe the same fundamental problems remain: control flow jumping all over the place, with actions-at-a-distance waiting to catch out the unsuspecting programmer.
So my advice on AOP would be to treat it like OOP, XML, Java, and all the other "silver bullets" that over the years have claimed to be the next big thing that will save our collective software sanity. Recognise the problem that it's trying to solve, realise the benefits of the particular solution(s) presented, and ignore all the hype!
I would guess the issues with AOP are similar to those with database triggers. You use them very cautiously when there is a very clear advantage.
In my opinion, database triggers are the GOTO for databases, based on countless hours of nightmarish debugging of other peoples' trigger-happy code.
Triggers are nearly indispensable for some things, like creating audit trails. For that task it is the best tool.
But lazy database design and lazy programming can invoke a trigger that invokes 3 other triggers that each invokes 2 other triggers all of which perform what ends up as a giant transaction affecting half of the 100 or so tables tied to a customer's record. Try to debug that. Or try to write new functionality, never quite knowing what the side effect of any database transaction is going to be.
Given the amount of 'buzz' about AOP, I am surprised to not see any comments from anyone in the trenchs with some experiences using it. Anyone?
Aspects: I've read about them, I've heard about them, but I am sceptical as whether the benefits actually come about. Are the debugging, side-effects, and perhaps unobvious program flow worth the gains?
<dig>Maybe we have scared all the Java programmers away?</dig>
Happy moony
I looked through a 50,000 line C++ program I wrote last year. There are 83 goto statements- I was damn surprised there were so many! An average of 8 goto's occur in each of ten different functions. Each of the functions is a large state-machine processor (they are actually PDU handlers for network protocols), so in each case the basic function structure is about the same. The goto's are there to break out of the state machine after detecting an error. Each error is completely handled where it occurs but of course invalidates the transaction, which cannot continue. So the goto is actually more natural in this specific case than an exception handler.
If you're going to (judiciously) use goto where appropriate in C++ programs, note one important thing: a goto may not span automatic variable declarations. This should make sense, since the goto target wouldn't how know to reset the stack-frame pointer. This restriction doesn't apply in C, which only allows automatic declarations at the top a function.
1. Make useless 5 page document
2. Have a link from Slashdot allow you to buy said document for $249
3. Profit!
- Any function that needs allocating memory is problem prone.
- I don't need to know where exactly the code failed, just that it failed.
- The compilers I use free NULL pointers gracefully.
The last one reduces the error handling to a minimum: just one label to go to (although, be careful, you do need to initialise them pointers as NULL).Important point, the same freeing code is used by the function as part of the normal, non-error flow. This is why the returned error_code variable is first initialised to 0 (all clear). goto statements are used to escape the normal flow when an error occurs, just like a break statement breaks out of a loop.
int foo()
}{
html code copy-pasted from the vim html output.
bundaegi is good for you
A very well respected (if a bit obscure) OO language is Objective-C. It has a few features that are analogous to aspects.
First it has categories, which allow you to add new methods, or replace the implementation of a method in a given class. You add a category to that class that includes, say, a replacement description method, and the new implementation replaces the old. Or you can add a path utility methods to the String class, as another example.
It also has "poseAs", which allows you to insert an object into a hierarchy. Say you have Class B which extends Class A. But you want custom behaviour to be accessible to all As children (including, for example, B). You create Class C, which extends A, and make it poseAs Class A. Now the runtime hooks all clesses that inherit A off of C, which replaces A. A still exists, but is in the background, providing normal inherited functionality to C.
These abilities were one of the things that made Objective C a very powerful OO language. In particular, it allows a particular kind of reuse, by virtue of allowing one to patch someone else's library without having source. So if you want to add the aforementioned path utilities to NSString, you just added a Category in your own code, and your code would run with the extended functionality in NSString (no one elses would, unless they used your category too). This means that often you can make the most out of someone else's code without a complete rewrite.
It isn't all powerful. There are access and visibility restrictions. It is also used to partition code for ease of organization and better modularization. Here's the point:
Because it is a well known feature of the language, you think in terms of categories, and you know to look for categories. This can be aided by tools, but you most definitely need to pay attention to them. But because of this, they are only "dangerous" if you aren't paying attention. And guess what! That's true of programming, period.
i - This sig provided by
In fact, I've never seen shorter code to accomplish such a complex task. Haskell must be doing something right when the language of choice to write Perl6 is not Perl5, but Haskell.
Woops, forgot to add a C2 Wiki entry for Objective-C.
i - This sig provided by
This makes code much clearer and avoids lots of dumb memory leaks that can happen when you make changes to a function. I never mention goto when I show this to people and they are very pleased with it.
This is all just my personal opinion.
I've used exceptions as a control structure to great effect in a C++ program I wrote recently. The original implementation had many dynamically allocated objects, looked dangerous, and was untestable. The exception rewrite was done very much in a functional programming style. All objects are allocated on the stack (very safe), and the overall structure was vastly simpler and actually testable.
My inspiration for this approach came from learning about continuations in Scheme... a C++ exception is essentially a special case of a continuation.
Yes, exceptions are slow, but in many (most?) cases it just doesn't matter.
AOP is not the answer to everything, but one of the main points of a talk I give at the NFJS show is that you can find tons of uses w/ development aspects without ever having to migrate them into production.
You can enforce (and detect violations of) various architectural decisions (i.e. no direct JDBC connectivity without going through a facade), define and enforce contracts (and leave them out of production), detect threading issues (How would you find all Swing thread abuse cases in a large, multi-threaded application?), get a sense of code coverage, etc. around any arbitrary cut of your system.
If you take the time to build around interfaces and support Object decoration via some variant of factories, you can do some of these things using Decorator and Dynamic Proxies, but you don't always have that luxury.
Tool support has been fundamentally lacking until things like recent versions of the AJDT. It still isn't perfect, but should serve to answer many of the early critics complaining about debuggability and losing track of what is going on.
I am an advocate of AOP in production systems, but you don't have to drink the whole glass to find aspects tremendously useful in development alone. With support for Ant-based builds and whatnot, it isn't even really an onerous task to give it a try.
Don't use AOP for things it isn't a good fit for, but there are quite a few things that can't be done as easily and elegantly without it (at least in Java). As others have pointed out, languages like Lisp and Objective-C have support for AOPish things built in.
I don't have much experience with multiple inheritance, but I understand that introduces some pain of its own. With inheritance, you have some core functionality of the base class and then you add on functions. With mixins (adding a clump of functions), I suppose you could do those with multiple-inheritance, but with using object composition as a substitute, you have to write all of these stupid little forwarding methods (or confess to the sin of violating the Law of Demeter by having too many levels of the dot notation).
Burton has a much more substantive report, that comes to a much more balanced conclusion - AOP is a useful and powerful technology, that is rapidly gaining traction in Enterprise Java, and developers and managers should be a process of measured adoption.
Free advertisment on Slashdot for a report that costs 250 bucks? My Ass.
I am very sceptic about aspect oriented programming. :))
But I do see it's use in some very specific points. These are logging and memory checks. This code can be performed with having no side effect on the actual program, while adding (temporal) functionality.
Aspects that do change the program flow or the results (ie that do not just monitor) are in my point very dangerous. A samples of this is persistency where aspects are also used a lot. It is the same as I look at templates and goto, they can be usefull for some specific tasks but don't use them for anything else and only use them when you know what you are doing. (so most people should not use them
There are no stupid questions, Just a lot of inquisitive idiots. (from a good friend)
A story that refers people primarily to a uninformative abstract on a $249 for-purchase paper simply isn't worthy of being an article on Slashdot.
If I could mod down the story choice, I would.
Sorry to be a downer, but this needed to be said.
--
Adult-Oriented Programming Considered Harmful?
This is a case of the cure being worse than the disease. Exceptions are more like COMEFROM than GOTO. They are not a reasonable or useful solution, and greatly complicate programming rather than simplifying it.
More importantly than replacing goto, they are an ugly patch for the problem that functions can only return one result (unless you do something like make a new struct for each function), so you can't return an error code along with the result. This is a fundamental error in language design that makes serious, fault-tolerant programming unreasonably difficult.
And before you say it, no, passing references to functions is not a reasonable substitute. Workarounds are not equivalent to features. Having to create temporary variables etc. for every function call isn't a reasonable option.
What specifically is "object oriented programming." When is the coding style object oriented? When it inherits and groups procedures in to classes? When if reflects off of classes? When it uses polymorphism? When code is reused in a specific way or something? I read a message that said that they didn't do object-oriented programming in lisp, what exactly does that mean?
I could make an argument that all non-functional programming methods could be considered harmful, simply because they are so much more likely to have bugs and it's that much easier to prove a functional implementation, albeit probably a bit more difficult to create one. I'd also argue that anyone who thinks that there is such a thing as "object oriented programming" is full of shit or doens't have much CS background; it's imperitive programming, the modeling of the problem space is object oriented and chances are that if you're a believer in OOM then you'll model the problem that way regardless of whether the implementation is functional, imperative or imperitive with aspects. Unless of course someone has a sound definition for "object oriented programming." Same for "aspect-oriented programming" Now Aspects are cool, I can see them as really really easy ways to simplify some specific problems, I can also see how you can radically complicate matters by using aspects and not remembering them or have defects in them. Yeah, so harmful in the same way as any imperitive technique can be harmful only with aspects the code may not look at all like what it is actually doing.
It's a buzzword intended to drive a lot of book sales and consultancy fees. Hell, throw that in your vocabulary along with "TCO", "ROI", "paradigm", etc, and ca$h in!
There are cases where AOP can play a useful and beneficial role and is a good feature to have. It is really up to the programmer to decide whether or not a feature would be useful or not in a particular setting. Programming languages should give users the freedom to make such determinations, since each application is different, each will have different needs. A set of language features that works great for one app may be insufficient for another. Some people criticise certian features because for the things that they have done they might not be useful, but in that case they shouldnt be obliged to use them. But the feature might be essential in another program, and if the feature is not avialable because someone else decided it didnt fit their needs for what they were doing and thus made the assumption that therefore no one else should be allowed to use it, the programmers task as been made more complex and barriers placed in their way and their job more difficult. The program language should give the programmer powerful tools to use so that if the programmers needs those tools they are avialable.
We can see it doesnt work here, because its close to home ...
Maybe it never worked ?
"However beautiful the strategy, you should occasionally look at the results" - Winston Churchill
That doesn't strike me as an "obscene" performance hit.
Given OOP, and overloading (which also makes debugging hell, if you weren't the one who wrote it), one wonders if the comparison isn't GOTO, but worse: COBOL's ALTER.*
I also note that the poster who mentioned both structured and OOP found a problem with OOP...but not with structured.
IMO, OO design is interesting...but OOP is nothing more than trying to enforce Ye Olde Good Coding Standards by compiler.
As usual, you can't *force* folks who write spaghetti/crappy code to write better code - they'll learn, or they won't (and hopefully, then, won't be promoted to management).
There's also the viewpoint that seems to be associated with OO that everything should be stateless...sort of like saying all data should be normalized. (Duhhhhh...)
The bottom line: my vote is for OOD, but structured code.
mark "and it's still functions, subroutines,
and parameter passing, not methods
and messaging...."
* My boss at the time I discovered that verb and I agreed that anyone using ALTER should be defenistrated, *then* fired.
hasn't use of Lisp been rising for about 50 years? When will it be used by more than 1% of programmers? I guess it hasn't reached the tipping point yet. at least its ahead of pascal.
Here's a link (http://en.wikipedia.org/wiki/Satire) that explains it all for you.
If you want to go somewhere, goto is the best way to get there. K Thompson
"Aspect-oriented programming (AOP) is intended to address common problems that object-oriented programming (OOP) doesn't address well, plus some problems that OOP itself created.
We have found another solution: Don't Use OOP. 99% of the bad things people attribute to procedural and database programming is wrong. It is usually because they were bad procedural programmers and bad database designers, and not the paradigm itself.
No paradigm has proven perfect, by the way. There is no silver bullet so far. Different paradigms just seem to be a personal preference.
From everything I've seen about Aspects, they look like a subset of Monads. Monads do the same sort of weaving of separated concerns, but as far as I can tell, monads are much easier to combine, have better granularity, simpler implementation, and a cleaner theoretical basis.
I realize I could be totally wrong, I never did finish reading all the papers on the Minimal Aspect Calculus article on lambda-the-ultimate.org.
Can you give me a better comparison between AOP and monads?
Shae Erisson - ScannedInAvian.com
Just like goto, which I would not totally consider harmful. Goto has its place in programs which need a precise command which maps directly to a processor jump instruction, therefore goto or similar constructs are widely used in system near programming.
I have to admit, I stayed away from AOP for a long time, but that stuff can be really useful if applied in the proper manner. The usual application has lots of sideconstraints which basically stain your algorithms up to a point, where you end up having 2/3rd side constraint code, 1/3rd algorithmic code. The side constraint is constantly the same over and over again, only altered slightly according to the state of the algorithm.
Now if you move that code in a well documented and clean manner into aspects, you can gain a lot. Aspects however are a deadly construct, if you go the AOP is everywhere manner and dont limit yourself to the basic rule, use it seldom and use it wisely but use it whenever you can achieve a cleaner code with it. If you go the aspect here aspect there route, you end up in a bigger mess than with a huge spaghetti code and 100 gotos in there.
Perfect examples for AOP are, to move the error handling code of checked exceptions out of the algorithms into aspects, another one would be to get a clean semi automatic transactional scope in methods which are called from the outside. Both things can be achieved with aspects in a much cleaner way, than with traditional programming, but if you use this stuff in that manner, document it and comment it, otherwise the persons who will follow you cannot see that the method is in a transactional scope.
So aspects are definitely worthwile using (I learned that once I jumped over the wall of considering it a deadly construct), but you really have to be careful to limit it to a few problem domains.
Step 1: sum up publically available research results from a university lab Step 2: advertise on /.
Step 3: profit!
Get it?
AOP sounds great for logging and debugging - and possibly all other things where you want to trace program execution.
Using AOP for pretty much anything else sounds like a recipe for disaster. Altering the program logic in invisible ways. Not good except to make yourself indispensable because no one can possibly understand your code.
The only thing worse would be to tell management all about AOP, so management can go to the programmers and tell them how to program. Better still, let the clients chime in on the debate. Oh, the fun!
...consider the source. Forrester Research is a bunch of do-nothing hacks where I'm concerned. One of our customers sent a report they'd gotten from Forrester on an aspect of our business, and it was filled with more half-baked assumptions, unresearched assertions, and self-generated opinions than you could shake a stick at. I sent a pointed rejoinder to Forrester to ask the authors of the report where they'd gotten their facts, and wondering where the backing research was for their assumptions, and so far I've heard nothing back. That was a year ago. Forrester Research can kiss my pale white overweight geek buttcheeks, early and often. (Point of order: I'm holding back. Don't get me started for real.)
After all it's clearly visible that we are dealing with integer variables here. C++ doesn't says anything to you?
So, of course, we have variables GOTO and OOP and post-incremented C.
But you are probably right about "==".
Aspects 'inject' behaviour into your classes. This is fine if the behaviour is completely orthogonal to the workings of your class, e.g. you're injecting enter/exit logging. If you start to inject functionality, however, the workings of the class can be substantially obscured. A number of the examples I've seen can be as properly done with more broken-down normal methods and a naming convention (e.g. before_x, after_x).
That said, chances are that the true benefits of aspect-oriented programming are not going to come from it being a mere curiosity to add to object-oriented programming. Someone is going to have to discover how to program in AOP where the focus is on AOP.
Possibly, it will have a journey like object-oriented programming. Started out with being used as object-based programming (just a more convenient way to associate data with functions), grew to some standard uses, then exploded into class libraries and eventually patterns.
Even 'interface-oriented programming' requires a slightly different tack than plain object-oriented programming does.
That's not to say that AOP will be the next actual big thing, or even really find its niche. There are plenty of good ideas that never really 'made it'. Time, and a whole passel of people with a lot of on their hands, will tell :)
Binary geeks can count to 1,023 on their fingers
Structured: discipline required to remember where what was placed and how it works and where it goes and what it does and so on.
OOP: who cares where what is or how it works or where it goes or what it does or uses.
I used to write programs in old Dartmouth BASIC in a tenth of the time C takes to do the same thing. Then C took a tenth of the time C++ took. I mean, figuring in troubleshooting any and all mistakes and my concepts versus what the machine thought and so on.
The next big OOP language should just be called something honest. Like Obfuscation+. Or TimeWaster.NET.
If my grammar and spelling are off, I am [distracted/tired/careless] (take your pick)
OMG OMG HERESY!!!! the aspect programmers MUST be CRUSHED!!!
ack!!! The company I work for has just begun implementing the balanced scorecard approach!!! Do you have a link?
I don't understand how you can spread FUD for 250$ a pop. Perhaps just with the headline? I guess people don't usually read the article anyway, right? :)
Tharkban (It is a signature after all)
I use GOTO in Jave - it is just called "throw"
Why don't you "try {} catch(something);" and use a hidden goto?
How can that be called Insightful.
... well that would be perhaps less portable :-(
The idea is that you don't nest if-statement in a way that nobody is ever likely to understend, but to structure your code using more advanced means. And yes, using "exceptions" is not enough of an improvement.
Goto's use should be limited to very few performance-critical parts. And if you wrote those parts in assembler instead of C
after err1: you just free the stuff allocated in "do something more", which has not happend if the first error happened. So your code is not working as you expected!
Plus: if you dont do a lot of testing, you are likely to miss the bug until your product is shipped!
Functions are very different containers of code than small blocks in a function.
The conventions about interactions between functions are different. Functions have a name. Functions have clearly different scopes with their input/output well-defined.
Functions are reusable. Functions are in general understandable separately while goto blocks have to be understood all at once.
In reality, almost no one does this. Because of the nature of AOP, it requires IDE support--see the AJDT (http://www.eclipse.org/ajdt/) for one example of what this looks like.
With IDE support, you can see exactly where aspects might affect your code, and you can easily navigate to the definition of these aspects. Tool support essentially gives you the desired scoping back, even though it's missing in the language.
Gregor Kiczales and Mira Mezini have a nice paper on this (http://www.cs.ubc.ca/~gregor/papers/kiczales-icse 05-aopmr.pdf), and I've done some more theoretical work validating the claim that modular reasoning is possible in AOP, given the proper module system and tool support (http://www.cs.cmu.edu/~aldrich/papers/open-module s.pdf).
no it does not. The author of aspectJ is also the designer of the common lisp object system, but he enahanced it's initial ideas. That is the reason that AspectL exists.
http://en.wikipedia.org/wiki/Pointy_Haired_Boss
Apparently the way to make money selling e-books is to write something Slashdot will post, then charge an outrageous sum for it on Forrester.
I'd also like to point out that AOP is just a fancy term for globally-accessible singleton (GAS). I've got GAS, but I don't brag about it. Sheesh.
Any connection between your reality and mine is purely coincidental.
RAII solves those problems. You can create as many objects as you like in the same scope, and if any constructor throws (or signals the caller to return an error code immediately), the compiler takes care of cleaning up all the already-initialized objects (and not the unitialized ones). You should never see an allocation except inside the constructor of an object whose destructor will always release it. try/catch is for providing explicitly different behavior in the event of an error. try/finally is for brain-damaged languages without destructors or deterministic finalizers.
The editors know that no Slashdotter can read more than 3 sentences on the same topic in a row without suffering brain death, so the fact that the headline article contained zero information and you have to pay for the real stuff was perfectly acceptable.
Six Sigma works great - for certain types of defined, measurable processes. Six Sigma worked great for GE when it wanted to make better jet engines. Not so great when they took it to NBC and tried to use it to make better episodes of Seinfeld. It's one of those cases where when all you have is a hammer, everything looks like a nail.
Tristan Yates
That is what AOP really sounds like to me. I have looked at several primers and basically come to the conclusion that most of the problems that AOP is intended to fix are the result of poorly thought out architecture.
Yes you didn't say, and in a way that is the point.
It is easy to make a mistake when you use the goto construct in that way. And you didn't even think about the mistakes one is likely to make but assumed that any programmer will be sensible enough to figure the correct sequence of labels and do the cleanup properly.
My guess is that this works well in about 60% of the cases. The other 40% are buggy. About half of these cases don't lead to program termination in the other half it would have been better to use exit() instead of goto.
If you have a JavaBean setter and getter that both do more than just set and return a field value, it's like writing advice around a "field".
Or think of a JavaBean as advice around the fields of a C struct.
This isn't "code-weaving", though, considering all the code is in one place.
"Love heals scars love left." -- Henry Rollins
They always were... Every article or comment I read from one of those consultant companies, normally even lacked basic CS understanding you learn within the first 3 semesters of computer science. The output of them is usually from clueless or business people for clueless and business people, with some CS coloring on top of the garbage they write.
As a teen I would booby-trap the Atari 800 computers at Gemco. A continous loop in Atari BASIC that went from 0 to 255 and back, that poked its value into the memory locations to change screen colors and sound pitch, initiaited when someone hit a key. Run it and turn the volume on the TV it was attached to all the way up, and then hide down the next aisle and wait for an unsuspecting victim to come by and witness them:
1) Jump out of their skin at the first touch of the keyboard, and
2) Cause a great scene and have to endure mucho embarassment, and
3) Make them wonder how they could've possibly "broke it".
Muwhahahaha.
Attention zealots and haters: 00100 00100
I hope I never work for or with your company. It sounds like you et al are bunch of idiots.
The only problem with your statement is you don't know c++.... (GOTO + OOP = C++ || (GOTO + OOP == C++)) But then who cares when lub is great. :D
The first usage of "AOP considered harmful" was (surprise!) at a JavaOne panel where Sun cordially ganged up on Kiczales, et al. With AspectJ (read: IBM) having a commanding lead in AOP and threatening with the upcoming AspectJ 5 release (generics and annotations) to blow away even the mechanistic alternatives, it's time for some pre-emptive attacks. Remember, fear breeds in the ignorant, so unless you're talking with someone who has a good understanding of AOP and how new programmers behave, get out the salt. "I used it once for logging" is not qualifying any more.
It's about selling tools and services: for significant systems, you can't get a picture of the entire program by inspecting local code or abstract models, no matter how clean your design. So you will need something. AspectJ takes the language approach, of putting the crosscutting into the code; this is better than using XML or intentional software or generative software because it's closest to the model of looking at source and verbalizing what you want. In any case, whoever defines the language or tools by which significant programs are understood gets the prize. Let's hope that the language approach and free software keeps up, or we'll be back to the days where you have to pay just to play.