June 09, 2003
Brilliant aspect article

Onjava has a brilliant article on aspect oriented programming. Well' actually it's the comments at the end that are brilliant. An intelligent reader discusses the concept of AOP and its practical usefulness at great length with one of the authors. Much of interest is said. One of the things is a discussion along the lines of "is OOP not a better match for describing the real world?". I have a strong opinion on that issue. The answer to the question is 'Absolutely Not'. Approx 20 minutes into your first course in object oriented design, you get to the problem of multiple inheritance, and the text will present you with something like the 'salary example' ("part time teachers" are both "part time employees" and "teachers", in either case they are "people" and have a "name", so which is it? The example is contrived, but text book examples usually are). Some kind of fix is proposed (outlawing multiple inheritance, using only interfaces) but the fixes rarely address the real problem, which is that in either case you are constructing nothing but a theory about the world you are modeling.
Using interfaces may look like the answer, but isn't really - at least not in strongly types, statically typed languages like C++ or Java. Claiming some property of a real world object is inherently dynamic. That dynamic aspect of language is poorly captured by most OO languages. You end up constructing actual objects with the desired properties and implementing some kind of reference to your original objects. This is worse than useless. Your model now contains synthetic objects with a rather abstract correspondence to your problem domain. Do this enough times and your code becomes a nightmare.
All kinds of bad design come from this need to construct objects mirroring the original model objects to add new typing, like the dreaded 'class hierarchy replication' (where you have your main model class essentially replicated in an other class hierarchy to add your jnew feature in a typedependent way)

Any technology that allows me to introduce the new look on old classes dynamically by actual reinterpretation of the original class instead of introducing additional classes is most welcome, and that is what (at least JBOSS) AOP looks like doing.

Posted by Claus at June 09, 2003 02:14 AM
Comments (post your own)
Help the campaign to stomp out Warnock's Dilemma. Post a comment.

Email Address:


Type the characters you see in the picture above.

(note to spammers: Comments are audited as well. Your spam will never make it onto my weblog, no need to automate against this form)


Remember info?