AOP @ ABB


home

AspectJ

documents

papers

contacts

What are we testing

Aspect Orientation was spawn out of the need to express in a more modular way crosscutting concerns, originally identified by Matsuoka, Yonezawa as inheritance anomalies in [4]. The term inheritance anomalies was coined by the authors to denote the problems that one has to work around in an OOP program in order to introduce a concern that affects your class hierarchy (and even methods within a class) by introducing duplicate code at distinct points within your programs code.

This systematic addition of code at different points within the programs code could not be captured and extracted with current OOP mechanisms (abstrac classes interfaces etc). As such the concern is said to crosscut the base program. The encapsulation of such a concern in a modular and well localized manner is your Aspect. Logically then, having the ability to capture aspects in a language the next step is to be able to introduce this aspectual behavior at the points within a programs execution. This introduction will provide the execution of aspectual code at the correct point in the programs execution time, so that your concern (refered to now as an Aspect) will perform its intented job correctly. That is, as if the code was manually inserted in the original program as we did before.

The above description can be refered to as the "birth" of Aspect Oriented Programming. Recently it has been identified that AOP is not a simple little hack to code some exaples that exhibit crosscuting concerns, but rather a programming discipline that can be followed not only by OO Programmers. Clear separation of concerns not only at design level but also at the implementation stage, allows for a higher level of modularity, eases extensibility/alteration and manageability of program code.

ABB's AIP system however, provides a different definition for the notion of an "Aspect". In particular, "an aspect defines a piece of information, and a set of functions to create, access, manipulate the information". Then, using "Aspect Objects" one can define the "Aspects" which an "Aspect Object" has. In this way within ABB' AIP system one can create modular units "Aspects" for concerns (or parts of the concern) that when grouped together under the definition of an "Aspect Object" will provide a representation of a real life artifact with its operations and functionality.

With the mouse example, I attempted to cast the initial problem as described in Matsuoka & Yonezawa form the bounded buffer example, to something simpler and not concurrent. In the place of "gget()" and other such functionality that the original paper introduces, in the mouse example we added double-click operations (similar other such operations can be implemented at will).

The given implementation uses AspectJ, but attempts to follow the design principles that ABB's AIP system has. In a little more detail, representing ABB aspects as AspectJ aspects Classes as Aspect Objects. The design constraints set forth by ABB's AIP should provide a solution to the Mouse problem that will not suffer from code taggling (crosscuting). This is more of a test to see whether the design decision in AIP can accomodate a modular and easily extensible solution without suffering from any inheritance anomaly issues.



A Computer Mouse Simulation

A company would like to test their new computer mice. There are 3 differnet mice :
  • Normal 2 button mouse
  • Three button mouse
  • Wheel Mouse (2 buttons and a wheel in the middle)
For all 3 models the left click button should report back the cardesian coordinates of the mouse pointer on the screen at the point of the click. Selecting an area to higlight denotes pressing the left mouse button, moving it a desired distance and then releasing. Automatically upon release, the higlighted area should be copied inside the mouse's buffer. The buffer can be then pasted back on the screen by pressing the right mouse button. The extra middle button in the Three Button Mouse provides a pop-up of the help menu. Finally the Wheel Mouse when rolled up moves your mouse pointer 10 pixes up and when rolled down moves your mouse pointer 10 pixels down on your screen. If pressed then the Wheel will act as a middle button. Implementing first the above scenario gets your simulator running. Then we have to add a logging mechanism for double clicking. However this logging mechanism will have to work only for the following mice with the corresponding buttons :
  • Normal Mouse : left and right button double clicks
  • Three Button Mouse : No logging is necessary
  • Wheel Mouse : left and wheel button double clicks
An OOP solution to the problem is possible, however the resulting code tends to have the logging concern spread out through out the classes (code adjustments via overriding need to be made even in the ThreeButton mouse class ). With AOSD the design can be clearer but also allow for easier extensibility of the program with the minimum alterations to the original code. The solution in AspectJ can be found here.