Aspect Oriented Software Development (AOSD)
Few days back I had a post titled Separation of Concerns. The topic was about how to divide/design your application into areas addressing specific concern of the problem. Now I call that vertical slicing of the problem. But if you analyze carefully there are certain aspects of the development which cut across horizontally. These most likely do not belong to the problem domain. For example, logging is one of them. You would have used a log framework and mingled log statements within the code for debugging and/or logging error traces. The log statements are never part of your problem, so it is kind of polluting the domain model. At the same time system management features such as logging and monitoring is rudimentary to any application. So how to take care of the horizontal separations at the same time preserving the vertical separations without polluting?
Welcome Aspect Oriented Programming (AOP) or Aspect Oriented Software Development (AOSD). Like Objects in Object Oriented Programming, Aspects are the core of AOP. An aspect represents a separation on the horizontal axis of the system. Say logging is an aspect, monitoring could be another aspect. The aspects are coded separately away from the problem domain code. Let’s define the whole system on a 2D plane (say a square or rectangle) and draw lines horizontally and vertically. Let’s also say that the horizontal lines represent the aspects and vertical lines represent the domain. Now there is a cutting point in when a horizontal line meets a vertical line. This cutting point in AOP is called a join point. In reality there could be multiple aspects cutting across one domain and these intersections are called point cuts. What needs to be done or how the system should behave when a join point and/or point cuts is encountered is called an advice. The aspect program contains all this information.
Now that is not the end to it. There needs to be some binding process that can bind the aspects and the domain code, so that the system when put into action will behave normally as though they were intertwined (meaning how you would have a code without AOP). AOP code is processed by a preprocessor that clubs the aspects and domain as defined by the join point, point cuts and advice and passes it on to the language compiler/interpreter. AspectJ is the AOP version of Java. While Separation of Concerns is a top priority for any system, AOP helps in keeping those SOC verticals clean and purely focused on the problem domain.









