Time is passing and the requirements for the developed systems and projects become much more large-scale and complicated.
The clear structure and "readability" of a program component's code are very critical and important today as they directly influence the increase of ROI. Object-Oriented Programming allows us to organize the program code so that we can trace a business-logic of program components and taxonomy (hierarchical relationship) of the business-processes and entries. However we are discovering some other troubles during a new system development. We can twist in the hands a quite successful class diagram for a long time in order to choose a way of implementing a DB connector object or some parts of the environment into certain classes.
The point is that the objects should be isolated. If we had declared the permanent objects in the global variables, we would not be able to use a testing module (Unit Tests, http://www.testdriven.com). Moreover, we can see that a business-logic of some methods is being lost behind the system code insertions such as logging, caching, synchronization, and code tracing. It goes without saying we have to separate a business-logic and a through functionality (cross-cutting concerns). These tasks can be solved by means of Aspect-Oriented Programming (http://eee.easy-hebergement.net/~wcandillon/dokuwiki/doku.php) relies on the other way. It uses XML for aspect declaration. PHP executes compilation itself with the aid of eval() function. It is an interesting approach, but a PHP code in XML looks very poor.
In my turn I suggest less radical approach that is less universal at the same time. It is a class library of Aspect-Oriented Programming paradigm's implementation into PHP. The library and the sample are available at
Let us turn to the sample. We can specify an aspect of through functionality (for example, logging) with the help of Aspect class initialization. Then we create the pointcut and the point methods, which will be affected by the pointcut. Next we just specify input/output points' program code for this pointcut. As you understand, we need to set the aspect pointer as a parameter to every component class and set up pointers of input/output points in every method ( advice::_before() and advice::_after() ).
Site Sapiens, specification of a language -
Found an error or have a suggestion? Let us know and we'll review it.
Suggest a Correction
Aspect-Oriented Programming and PHP
0 views
Comments (0)
Please sign in to leave a comment.





No comments yet. Be the first to comment!