Thursday, November 16, 2006

Interactive Grid with Your Own Hands

I am sure being ‘pampered’ by GUI of desktop applications, users find interfaces of web-applications as extremely uncomfortable. Their notes, probably unexpressed, are timely within AJAX Age. Besides, it is not so difficult to make web-applications more user-friendly. I will not describe whole variety of interface forms in this article, but will concentrate on such an indispensable element as a grid. Almost every web-application needs linear data list management. DB record management of PhpMyAdmin is likely a classical solution in this field. It is a popular solution, but it demands page reloading for every operation, data loss is possible and so on. Let us think about what requirements should be included to be a user-friendly interface should have. The user should have the ability to sort the list by fields, filter the list, the possibility to assign a range of selecting and pagination. With all this going on, only part of the application window should be changed.

As far as you probably know, basis of AJAX is XMLHttpRequest. It is a Java Script instrument, which allows to perform requests to a remote server script and receive its responds. Thus, when a user is initiating some event (for instance, click to an icon), we can immediately inform the server script. When the server script receives the request, it starts to ‘find out’ in referred parameters what it should return, for example, the record list, which is sorted by some user input criterion. Java Script retrieves the list and displays it in a table area. The user watches, with pleasure, the line order of the table being changed to his input request., while all other forms of this application window remain unchanged.

Figure 1. Model of the solution
Figure 1. Model of the solution

How to do it? Use of XMLHttpRequest is not a difficult task. However, we can simplify this by adding a ready script library to our arsenal.. I liked a solution from YUI toolkit (http://developer.yahoo.com/yui/), which is known as Connector. With help of unpretentious construction, YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData); we can send POST-parcel to the specified address and analyze the response from the server script with the function, assigned within callback.

So, by using HTML, we describe the interface to the future of the grid. We omit areas, which are dependent on server script responds (records list, indicator of record number), but leave “anchors” so that we can manage content from those areas dynamically. It can be any sort of HTML-containers with the assigned unique ID. Next, we describe the functions of server respond processing. For example,



Listing 1

var handleSuccess = function(o){
if(o.responseText !== undefined){
document.getElementById(divName).innerHTML = decorateList(o.responseText);
}
};

var handleFailure = function(o){
if(o.responseText !== undefined){
document.getElementById(divName).innerHTML = 'Server Error';
}
};

var callback =
{
success:handleSuccess,
failure:handleFailure,
argument:['foo','bar']
};




Likely, someone will question “But what do we receive from server?”. We receive content of server script console. In the simplest case, it will be HTML of the updated table. But it means mixed data and its decoration. I.e. every table modification will demand modification of the server script, which will adversely affect readability of application business logic. Classical universal solution of data structure transferring is XML. In that case, we will have to analyze reported content each time with Java Script and form HTML or give that charge to XSLT. You can read about it in the “AJAX:Getting started” article at http://developer.mozilla.org/en/docs/AJAX:Getting_Started. But I suggest to use another more comfortable format JSON(http://en.wikipedia.org/wiki/JSON ). It will allow to transfer less amounts of data, will not have difficulty with special symbols and we will have no need to analyze server script responds. JSON is for Java Script ready to use construction.

So, now we only need to define set of parameters of various events and add their processing into the server script. Assume, if “Show” button is pressed, we are passing to the server script, taken from INPUT TEXT the list offset and number of displayed records. The server script inserts those values into SQL query and transforms the record list to JSON form. We can “run” about received array lines and decorate them with HTML.

Figure 2. Commercial grid sample
Figure 2. Commercial grid sample

As you can see, the new opportunities are coming to us. We can make Java Script on the client side to repeat requests automatically right up to successful transaction, if there are any troubles with a network connection. We can realize adequate indication of the process. We can make the filters more interactive by sorting the list automatically in accordance with the entered part of the filtration key. Well, we can use as much of our imaginations as we allow.
You can download the code archive (http://www.phpclasses.org/browse/package/3481.html), which contains all of the files you will need to create the working examples presented here.

Friday, November 03, 2006

Aspect-oriented Software Development and PHP

Aspect Oriented Software Development (AOSD) is a methodology meant to implement new aspects in software component using external components, but without altering the code that implements the core functionality.



The AOSD concept was applied originally by Java developers. They developed a compiler that implements the AOP (Aspect-Oriented Programming, an implementation of AOSD) white box approach, i.e. the compiler the merges the code that implements the software components core functionality with the necessary code alterations to implement the new aspects where necessary.


This paper provides an introduction into the paradigm of aspect-oriented software development (AOSD). It includes a multitude of practical examples, provided with a view to objectify such abstract approach as AOSD, as well as to help the reader easily grasp its essence and advantages. The paper is primarily intended for programmers working with PHP. Its aim is to demonstrate a way of applying AOSD in PHP-based projects already today.




Introduction



Object oriented approach has been popular for a number of years. Its advantages can hardly be visible within short-term projects, yet any major long-term one simply cannot do without it. Object-oriented programming languages provide the tools necessary to present business logic in a demonstrable form. Today UML Class diagram (http://en.wikipedia.org/wiki/Unified_Modeling_Language) does suggest itself even on the stage of developing the system logic.



Demonstrable business logic makes it easier for new participants to join in, helps to save time for those developers that come back into the project at later stages. It also considerably reduces the number of mistakes. But is implementing object-oriented approach enough to develop the demonstrable business logic? Obviously not. To create smart object-oriented programme architecture is not an easy task – unless you were able to successfully implement methods described in the book by Martin Fowler called Refactoring: Improving the Design of Existing Code.


Yet even now one can find not encapsulated functionality (crosscutting concerns) in a number of various classes (logging, caching, synchronizing, tracing, monitoring, debugging, run a security check, start a transaction, open a database connection). AOSD (aspect-oriented software development, http://en.wikipedia.org/wiki/Aspect-oriented_programming) is capable of organizing this kind of program logic.



What is AOSD?



Aspect-oriented software development (AOSD) is a relatively new approach in the area of developing business applications. This approach is based on the notion of Aspect. Aspect is a standpoint for considering some other notion, process or perspective. To be able to quickly discern the underlying idea of the approach, let us try and consider various aspects of a web-site. Information architecture defines a site’s structure. Usability refers to the degree of site’s friendliness towards the user. Graphic design determines the visual perception of a site. The functional model describes its business logic. All of them are various components of the web-site development process, and each component requires specific resources, approaches and solutions. For a project to be successful, all of the aforementioned components are to be efficiently developed and implemented. Lest someone should find this example too complicated, let us consider a simpler and more universal scheme. When an apartment building is being designed, the architect had to first elaborate a framework, then the wirework scheme, then the water supply plan and so on and so forth. Each of the stages in this process is a different aspect, a different perspective of the project. No matter how trite it may sound, a similar approach can be implemented in software development for identifying various aspects of business logic within applications. More than 20 years ago Bjarne Stroustrup (http://en.wikipedia.org/wiki/Bjarne_Stroustrup) arranged the programme code within C++ into sets of logical entities, whose behaviour and interactions could be defined in a number of ways (inheritance, encapsulation, abstraction, polymorphism). It is a reliable and time-tested paradigm of software development, known as object-oriented programming. Yet this approach has certain limitations as to the decomposition of application business logic aspects. Over the years that have passed since the time this paradigm emerged, a number of approaches aimed at overcoming the said limitations have emerged. Among them are adaptive programming, composition filters, aspect-oriented programming, hyperspaces, role-modelling, subject-oriented programming and so on. Lately, the development of such approaches has moved to the area of AOSD. As we have already pointed out, the cross-cutting concerns code is going to be distributed among the various modules, which will inevitably impair the quality of the software with regard to the transparency of business logic, its adaptability and upgradeability. The aim of AOSD is to isolate the cross-cutting concerns and place it outside applications’ business logic.



Let us consider some integrated web-application, for example CMS, and try to imagine at what point and in what way we are likely to encounter the above-mentioned difficulties. Suppose, a certain number of system functions require converting input data from XML to arrays. Due to the fact that in this case XML-parsing aspect involves only a limited number of functions, it doesn’t imply considerable extension. As it is clear, in such case there’s no need for extensive decomposition and therefore no need for AOSD to be implemented. The simplest and most logical solution would be to include this procedure into the root class method (or, otherwise, into the external class, depending on the specific circumstances) and activate it when it’s needed.


Acceptable decomposition

Figure 1. Acceptable decomposition



Yet no manipulations with objects are going to help if we have to monitor the productivity, and our task is to take on demand the readings of all functions performed, at their entry and exit points. An attentive reader would suggest that we should resort to the previous example and use trigger for activation or deactivation of statistic data capture. Well, we can only warn him or her that, should a need arise for logging system transactions in specified cases, it will become necessary to recall all the details of programme architecture and to reorganize it.


Inadmissible decomposition

Figure 2. Inadmissible decomposition



It would be much more practical to task the system with handling specified events in certain objects within a given aspect. Suppose, after some time new security requirements have to be introduced into a large and sophisticated project. We then create a procedure for additional security checks and task the system with carrying out this procedure at the activation of specified methods within the security aspect. This is implied by the paradigm of AOSD. We set up a new abstraction level outside the existing program architecture, and then in it we declare a functionality that in some way is applicable to the whole of the system. As you can see from Figure 3, it is possible to define program procedures that attend the system, say, within the security aspect, and then place them outside the main classes. In the same way we can treat the input data validation aspect procedures. Thus, with each time we make the business logic more evident and demonstrable. As a matter of fact, what we get as a result is a clearly defined business logic in system’s main classes and precisely distributed outside the essential model cross-cutting concerns.


Aspectual decomposition

Figure 3. Aspectual decomposition



Let us sum up:


· the aspect-oriented approach is based on the principle of identifying common program code within certain aspects and placing the common procedures outside the main business logic;


· the process of aspect orientation and software development may include modelling, design, programming, reverse-engineering and re-engineering;


· the domain of AOSD includes applications, components and databases;


· interaction with and integration into other paradigms is carried out with the help of frameworks, generators, program languages and architecture-description languages (ADL).



Basics of Aspect-Oriented Approach



Aspect-oriented programming allows developers to organize cross-cutting concerns into individual declarations – aspects. It provides possibilities to define functionality for specified program execution points JoinPoints (method activation , class construction, access to a class field etc.). Languages that support aspect-oriented programming (AOP) more commonly employ functions for a set of points – Pointcut. The functionality at those points is determined by the program code which is politely referred to as Advice (AspectJ). Thus, aspects describe crosscutting concerns for a specific set of system components. The components themselves include only business logic that they are supposed to implement. During compilation of the program the components are associated with aspects (Weave).



To better grasp the basics of aspect-oriented programming, let us once again consider the example, which involves defining the productivity monitoring aspect. (see Figure 2). Suppose, we want to take the timer readings at entry and exit points of all the methods within such classes as Model, Document, Record and Dispatcher. So, we have to introduce into the Logging aspect a Pointcut with the listing of all the required functions. To cover all of the methods of a certain class, most AOP-supporting languages employ a special mask. Now it is possible to define the needed Pointcut. We set up Advice at the entry (Before) and exit (After) points to the methods listed in the Pointcut. Usually, Advice in AOP-supporting languages is available for such events as Before, After and Around, though sometimes other events are also present.



Thus, the following basic AOP declarations may be singled out:



Aspect – a definition of a certain set of cross-cutting concerns performing a specific task;


Pointcut – a code of an Aspect’s applicability: defines when and where the functionality of a given aspect may be applied (see Figure 3)


Advice – a code of an object’s functionality: a direct functionality code for the specified events. In other words, this is what is going to be executed for the objects listed in the Pointcut.



Still too complicated? Well, I think everything will become clear once we introduce some practical examples. Let us begin with the simplest of them: http://www.phpclasses.org/browse/package/2633.html. I wrote this small library with a view to demonstrate both the advantages and availability of AOSD. Besides, you don’t need to know every detail of PHP or custom software to be able to use this library. It is sufficient just to enable aop.lib.php in your scripts in PHP 4 (or later version) in its standard configuration.



It is possible to define a certain aspect for crosscutting concerns (let’s say, for keeping transaction log), through initiating the Aspect class:




>>begin textbox<<


Listing 1


$aspect1 = new Aspect();


>>end textbox<<



Then we set up a Pointcut and specify the methods it affects:



>>begin textbox<<


Listing 2


$pc1 = $aspect1->pointcut("call Sample::Sample or call Sample::Sample2");


>>end textbox<<



The only thing remaining is to specify the program code for entry and exit points for the methods of the current pointcut:



>>begin textbox<<


Listing 3


$pc1->_before("print 'PreProcess<br />';");


$pc1->_after("print 'PostProcess<br />';");


>>end textbox<<



In the same way we can define an additional aspect, for example:



>>begin textbox<<


Listing 4


$aspect2 = new Aspect();


$pc2 = $aspect2->pointcut("call Sample::Sample2");


$pc2->_before("print 'Aspect2 preprocessor<br />';");


$pc2->_after("print 'Aspect2 postprocessor<br />';");


>>end textbox<<



In order to enable one or several aspects just use the Aspect:::apply() function:



>>begin textbox<<


Listing 5


Aspect::apply($aspect1);


Aspect::apply($aspect2);


>>end textbox<<



As you probably know, before PHP 5 emerged handling method and class events was somewhat of a problem. Whereas for global events – for instance, PHP errors, - one can develop a specific handler, for handling events at entry and exit points of methods it is necessary to “manually” insert some kind of “notifiers”. In our case we’d need to insert special Advice::_before(); and Advice::_after(); functions:



>>begin textbox<<


Listing 6


class Sample {


function Sample() {


Advice::_before();


print 'Class initilization<br />';


Advice::_after();


return $this;


}


function Sample2() {


Advice::_before();


print 'Business logic of Sample2<br />';


Advice::_after();


return true;


}


}


>>end textbox<<



As it is clear from the above example, inserted before and after method’s business logic code are “notifiers” for these events. When PHP processor finds such a “notifier”, it checks for the active aspects. In case there is one, PHP checks for the current function specified in the Pointcut. If the function is there, it is activated for the given event (for example, for Advice::_before()). As you see, it is quite simple. But what is the practical value of this approach?



Suppose, we have inserted “notifiers” into all the class methods of our scripts and enabled aop.lib.php library. Then one day a need arises to obtain a detailed report on the distribution of workload among the functions of our project. We set up an aspect and define its Pointcut, which includes all functions within the project:



>>begin textbox<<


Listing 7


$Monitoring = new Aspect();


$pc3 = $Monitoring->pointcut("call *::*");


>>end textbox<<



As it is clear from the example, it’s possible to use *::* mask. Then in Advice we can employ a conventional function for the calculation of exact time in milliseconds (ms):



>>begin textbox<<


Listing 8


function getMicrotime() {


list($usec, $sec) = explode(" ",microtime());


return ((float)$usec + (float)$sec);


}


>>end textbox<<



With its help we can take time readings at entry points of each of the project’s functions and compare it with the readings at the functions’ exit points; the obtained time of business logic operations within the body of the function is stored in global report variable. The only thing remaining is to display the report at the end of the program cycle. An example of employing productivity monitoring aspect is presented in the sample_trace.php script found in the archive of the distribution kit.


Moreover, this library allows you to register your own system events and define cross-cutting concerns for them in the future. Your own events could be defined in any place of application code:



>>begin textbox<<


Listing 9


Advice::_event("AllAPILibrariesAreLoaded");


>>end textbox<<



We could add event handler for the necessary events to make an additional decomposition or include a new plug-in in a complete application:



>>begin textbox<<


Listing 10


function MyController() { return "It’s controller";}


$aspect3 = new Aspect();


$pc3 = $aspect3->pointcut("call *::*");


$pc3->_event("AllAPILibrariesAreLoaded", "MyController();");


$pc3->destroy();



Aspect::apply($aspect3);


>>end textbox<<




Lest you should get an impression that AOSD can only be used for certain specific tasks, let us consider another example.



PHP is quite tolerant towards various types of variables. On the one hand, this is a very positive feature for it means that there’s no need to constantly check for compliance with the specified types and waste time for the declaration. On the other, this could lead to errors.


In case a project contains a huge number of functions, it is hardly possible to remember the syntax we have devised for them. Yet misplacing even one single argument can cause unpredictable changes in a function’s behaviour. Can AOSD be of help in such situation? Definitely! Let us recall the diagram in Figure 3. As you see, classes Document and Record contain similar methods add, update, delete, copy, get. A well-organized program architecture presupposes similar syntax for these methods: add($id, $data), update($id, $data), delete($id), copy($id1,$id2), get($id). AOSD can help us to organize the program architecture – as well as our own activities. We can set up input data validation aspect and define the Pointcut for the Document and Record class methods. The add, update, delete, copy and get entry event function can check for the type of the first argument. If the latter is not integer, an error has surely occurred. It is also possible to set up the second Pointcut for the add and update methods. What is going to be checked in this case is the type of the second argument, which obviously has to correspond to the array type.



In this way we can place transactions logging outside the project business logic; now it is possible at any time to define functions, which require additional checks for security etc.



Of particular interest is the fact that with the help of AOSD we can provide for a specific system error warning to be displayed for a specified set of functions. Suppose, a number of our functions participate in setting up WML (WAP), WSDL (SOAP), RSS/ATOM or SVG mark-up code. Obviously, in this case it is unacceptable to display HTML-code with the error message. The “notifier” in PHP error processor will make the system display the message either in XML, or use non-visual means (for example, send a notification via e-mail).



Anyone who at least once participated in the development of commercial software, knows how difficult it is to solve the issue of updating the final product. Certainly, we are all aware of the existence of the version control software – for instance, CVS (Concurrent Versions System, http://en.wikipedia.org/wiki/Concurrent_Versions_System ).Yet the problem is that every new product, based on the previous one, requires certain customization, and more often than not it is not at all easy to find out whether the update is going to affect areas customized for a specific project. Some of you have surely encountered cases when after an update you had to restore the whole project from back-up copies. And now just try to imagine a case when “disappearance” of customized features is noticed only a long time after the update! “Well, where does AOSD come in?” you may ask. The thing is that AOSD can exactly enable us to address this issue: the whole customization code can be placed outside the project’s business logic as crosscutting concerns. You only have to define the Aspect of interest, specify the area of its application (Pointcut) and elaborate the corresponding functionality code. It is worthwhile trying to imagine how exactly this is going to work.



Let us recall my favourite example featuring content management software. Such product is sure to contain a function for displaying recordsets Record::getList() and developing code for these sets View::applyList(). Within arguments Record::getList() receives a recordset indicator and data selection parameters. This function produces an array with data on the results of selection. View::applyList() function receives this array at the input point and generates the format code – for example, HTML code for a table. Suppose, in our product a goods catalogue is presented as such recordsets. This is a universal solution for a commercial product, yet for every specific project based on this product it is necessary to introduce into the sets an additional column. For instance, tables in the original product have Stock Number and Item fields, while we need to add one more, Customer Rating field. In order to do this, we write Advice for the function Record::getList(), which establishes that an additional column is inserted into the returned array at the end of the runtime.


If the View::applyList() function is incapable of adjusting itself automatically for the changes in the input array, then we shall have to write Advice for this function as well.


Let us assume that later on the client demands that we should mark out all the entries in the sets, which include goods not found in store at the moment. In this case we add Advice for the View::applyList() function, in which we check for the value of the Available in store attribute. Notice that we may set up a separate Plugins folder for aspects declarations and scripts that include their funcyionality. Thus, we shall have a complete set of customization features for any sort of a project stored in one specified folder, and there will be no upgrading problems whatsoever. We’ll be able to easily upgrade any system scripts, except for those stored in the Plugins folder.



Aspect-Oriented Software Development in PHP



At present there are a number of advanced projects, whose authors have introduced various techniques of AOSD and PHP implementation. The AOPHP project (http://www.aophp.net ) includes a PHP preprocessor written in Java 1.5. We can write a usual PHP-code, but we’ll also have to notify the preprocessor of our intention to use AOSD. To do this, we’ll use <?AOPHP ?> structure instead of <?PHP .. ?>. The crosscutting concerns can be put into separate scripts.



>>begin textbox<<


Listing 11


before(): execr(add($x,$y)) | execr(sub($x,$y)){


echo "<font color=red>Im About To Add/Sub $x & $y</font><br>";


}


>>end textbox<<



If necessary, these scripts can be enabled by issuing instruction while declaring AOPHP code:



>>begin textbox<<


Listing 12


<?aophp filename="aotest.aophp,aotest2.aophp" debug="off"


// PHP code


?>


>>end textbox<<



Seasar.PHP project (http://www.seasar.org/en/php5/index.html) employs a different approach. Its authors use XML for structuring aspect declarations, while integration is carried out with the help of PHP, which then executes the resulting code through eval() function.



MFAOP project (www.mfaop.com ) is based on an approach slightly resembling the one I mentioned in the above examples. The project’s author suggests that first one should set up a Pointcut and then use it according to what is needed:



>>begin textbox<<


Listing 13


$pointCut = new PointCut();


$pointCut->addJoinPoint('Example', 'Foo');


$pointCut->addJoinPoint('Example', 'Bar');


$test1 = new Aspect($pointCut, before, 'echo "Before $MethodName";');


$test2 = new Aspect($pointCut, after, 'echo "After $MethodName";');


>>end textbox<<




Unlike in aop.lib.php library, when using this solution there’s no need to manually insert “notifiers” for each function. Yet we’ll have to install an additional PECL Classkit extension on the server.



From my point of view, the most elegant solution has been found by PHPAspect project (www.phpaspect.org ). This was possible thanks to the effective use of new capabilities provided by PHP5, and in particular – the possibility to set up abstract classes. PHPAspect introduces into the language of PHP a specific structure; which presents the declared aspect in a demonstrable form.



>>begin textbox<<


Listing 14


aspect TraceOrder{


pointcut logAddItem:exec(public Order::addItem(2));


pointcut logTotalAmount:call(Order->addItem(2));


after logAddItem{


printf("%d %s added to the cartn", $quantity, $reference);


}


after logTotalAmount{


printf("Total amount of the cart : %.2f €n", $thisJoinPoint->getObject()->getAmount());


}


}


>>end textbox<<




As it’s clear from the example, the interval of the specified aspect is precisely defined. The Pointcut and Advice are set up in a way that is so concise and yet capacious, that one may think this is the “native” PHP syntax. This project provides handling capacities for 7 (!) types of Join point events: call, execution (exec), class construction (new), attribute write-in (set), attribute read operation (get), class destruction (unset) and block catching (catch). There are three possible types of Advice: before, after, around. This project developed unusually flexible masks for defining surveillance intervals in Pointcut. Thus, for instance, it is possible to assign intervals for all classes with the specified prefix in the name:



>>begin textbox<<


Listing 15


new(*(*));


exec(* Order::addItem(2));


call(DataObject+->update(0));


>>end textbox<<



To be able to install PHP Aspect, you’ll need PHP 5.0.0. or later versions, and have PEAR Console_Getopt, Console_ProgressBar, PHP_Beautifier libraries installed.



This project was successfully presented last year at the PHP conference (http://afup.org/pages/forumphp/) in France (this is where the project originates from), and as for as I know is making good progress. It is possible that Zend Inc. will include the experience generated by this project into the following versions of PHP.



Conclusion



Obviously, AOSD is not a universal solution. AOP is not going to eliminate all bugs or develop software on its own. I doubt that every developer using aspect-oriented programming will get a Nobel Prize. Moreover, this approach is hardly going to become the dominant one in the future: object-oriented approach has been popular for 20 years, yet many developers still confine themselves to procedural code. On the other hand, the advantages of AOSD before object-oriented programming are as obvious as OOP’s advantages before procedural programming. I think I’ll be on the safe side if I say that those developers who use AOSD are one-step ahead of the others. Their code is clearer, easier to perceive, it contains less errors and can easily be developed. Thus, AOSD engineers are capable of implementing larger-scale, more reliable and versatile projects. Importantly, AOSD does not require complete retraining of developers. AOP doesn’t alter programming logic drastically, as it was the case with transition from procedural to object-oriented programming. AOSD just extends it. Developing a new program architecture, you only extract from the objects everything that you think doesn’t fit there and find a suitable place for it. Imagine that for years you’ve tolerated a piece of sculpture, which totally disagrees with the overall design of your home, but which you treasured as a gift. And then one day you find an inconspicuous niche in the wall where the sculpture seems to fit perfectly. “Well then,” you’d say in that case, “this is where it really belongs!”



Apart from all that has already been said, AOSD is easy to get used to – unlike, for example, TDD (http://en.wikipedia.org/wiki/Test_driven_development). At first, one could try and put into aspects simple crosscutting concerns, like logging, and then gradually extend decomposition of program architecture, accumulating in aspects various domains of the application.



Perhaps, some are confused by the fact that at present PHP does not officially support AOSD. Yet in this very article I have presented several examples of how you can easily integrate basic AOSD approaches on your own. It is the essence of AOSD that is important, not the particular way in which it is implemented. Whatever approach you chose, if you were able to achieve efficient decomposition in program architecture it is inevitably going to improve the quality of your product. Today AOSD is supported mainly by extensions to popular programming languages, yet the leading players on the market are not going to stay out of it, and AOSD is gradually finding its way into the popular programming platforms (http://www.internetnews.com/dev-news/print.php/3106021). AOSD is not going to become a new technological revolution, yet evolution, on the other hand, is inevitable. Whether you follow it or take the lead is a matter of your own choice.



Resources & References


[1] Pan-Wei Ng, Ivar Jacobson. Aspect-Oriented Software Development with Use Cases. Addison Wesley Professional (Dec 30, 2004), ISBN: 0321268881.


[2] Robert E. Filman, Tzilla Elrad, Siobhan Clarke, Mehmet Aksit. Aspect-Oriented Software Development. Addison-Wesley Professional (October 6, 2004), ISBN: 0321219767.


[3] Ramnivas Laddad. Aspect Oriented Refactoring. Addison-Wesley Professional (September 29, 2006), ISBN: 0321304721.


[4] Ivan Kiselev. Aspect-Oriented Programming with AspectJ. Addison-Wesley Professional (July 17, 2002), ISBN: 0672324105.



· http://en.wikipedia.org/wiki/Aspect-oriented_programming


· http://eclipse.org/aspectj/


· http://phpaspect.org/


· http://www.aophp.net/


· http://www.seasar.org/en/php5/index.html


· http://www.phpclasses.org/browse/package/2633.html


· http://www.informit.com/articles/article.asp?p=375541&rl=1


· http://www.devx.com/Java/Article/28422


· http://www.scriptol.org/history.php


· http://www.ercim.org/publication/Ercim_News/enw58/mens.html


· http://www.cs.ucl.ac.uk/staff/C.Courbis/papers/12jan04Board.ppt


· http://www.computerworld.com/developmenttopics/development/story/0,10801,85621,00.html


Discover a World of Fascinating People


It is common to encounter success stories that begin with the words: “I’ve have been lucky in my life. I’ve made good friends and met like-minded people who have helped me from the beginning. Thanks to them I have achieved my dreams”. It is evident that not everyone reaches their goals and not everyone us is lucky enough to meet people who can direct their life towards success. The Internet epoch has introduced a tremendous new option in the realm of communication. Social networking through web-portals has gained popularity, providing individuals with an alternate form of communication. Internet communities have been created allowing users to exchange thoughts and build friendships based on similar interests. The contemporary net communities provide tools that support an individual’s spiritual and professional growth.


The social networking framework on the Internet is similar to our own social networking framework in real life. We gather for social networking in places where other individuals with similar interests are. For some parties or nightclubs would be where they would find the best networking opportunities. Depending on your interests it could be anywhere - athletic clubs, professional meetings, conferences, exhibitions, the opportunities are unlimited. Anywhere that there is a social gathering that piques ones interest there is an opportunity for social networking. Internet communities operate in a similar way. Individuals are drawn to these communities based upon their interests and those of their friends. After entering the community they begin to network with individuals who share similar interests. Those individuals also have their own network of contacts allowing for the number of contacts to grow in geometric progression.



If interests of persons in your friends list are really close to your, likely our friends’ network will develop quickly. In the case where some of your first contacts have similar interests, it is probable that your number of contacts will become independent and show a high quality growth.



These Internet communities can be divided on two basic groups: general interest community and professional business communities. I hope, the following table helps to get your bearings rapidly in great set of social networking services.



General interests’ community



































MySpace.com



The most popular community of this social networking category. It has a user-friendly interface and a wide variety of users.



Friendster.com



The largest community within this social networking category. It allows users to work with photo albums, blogs, and create a net of friends. This community also allows users to create joint file archives and broadcast messages within a given network of friends.



Hi5.com



This community provides all the basic functions of social networking but is most often used as a dating service.



MeetUp.com



This community is oriented on bringing together user groups based on their interests with the purpose meeting in the future in person.



Orkut.com



This community is accessed by invite only. It is an elite club where a user needs an invitation from one of community members in order to gain entry to it.



360.yahoo.com



This community requires the user to present him/herself and find the users with similar interests. It offers an integration with the popular exterior services such as Yahoo Groups and Flickr.com



Spaces.msn.com



The Spaces community has a comfortable interface of a personal space administration. In particular this service contains pictures uploading, which approaches to MS Windows Explorer. This service is able to spread within friends’ network news about blog updating through MS Messenger.



Hometown.aol.com



The America online community allows the user to create their own web page, decorate it, and notify the other users about its existence.



Whoat.com



This community connects users who are in the same location. It’s enough to set your location in the system and it will bring your together with those who are in the same zone as your mobile phone, PDA, PC.



Sms.ac



The community of “mobile” users. The project helps to create personal, mobile-available web space. Within this space the basic social networking options are provided.



Closedsociety.net



This community is accessed by invite only. A user needs an invitation from one of community members in order to gain entry to it.




Professional business community




























LinkedIn.Com



This is the most well known professional community. The project is optimal for job seekers, researching professionals in certain fields, and for establishing contact with other professionals.



Ecademy.com



The different business fields professionals’ community. Paid participation.



OpenBC.com



Sometimes this project is being called euroversion of LinkedIn. Though OpenBC is inferior to LinkedIn in a number of participants. At the same time, OpenBC lets to adapt interface for user’s native language and provides a wide variety of many other services.



Spoke.com



Paid project. It helps to user in a new business prospective search.



Ryze.com



Project offers all the basic options for social networking and it are being used often as a general interests’ community.



Ziggs.com



The project lets to create users’ profiles, which are going to be indexed in search systems. The typical for search systems interface is being used for the business contacts finding.



Zerodegrees.com



This service is supposed to connect you with the influential people who could help to boost your career and business.



Tribe.net



This project includes both traits of General interests’ community and Professional business community. At present time Tribe is more often being used for social purposes. For example, you moved to a new city. In this case Tribe will help you to find out everything about the accommodation, restaurants, concerts and others.




The legendary project LiveJournal.com can be called the pioneer of general interests’ community. It is quite possible that the mentioned project is the most active blogging system so far. In a recent time MySpace.com community gained the most popularity. This particular community became the first among the top requests of Google’s users in 2005 (http://www.google.com/press/zeitgeist2005.html). This community counts more 47 million of users. The following is Friendster.com the previous leader (21 million). How did it manage to come out into leaders? The answer is obvious – the wide variety of free services. Besides the basic options of these kind of system, such as a personal page creating, conducting of blogs with the comments, photo albums and inner email, MySpace offers a lot of options for user’s pages arranging, creating the general interests’ microcommunities, the users ranging, conducting the forums, coverage of local events, co-participation in games and even musical online albums for songs’ authors creating. Undoubtedly, the large-scale players couldn’t leave without their attention such a “piece of pie” of the Internet market. As a result, such social networking solutions appeared: Microsoft (http://spaces.msn.com), Yahoo (http://360.yahoo.com), Google (http://Orkut.com) and AOL (http://hometown.aol.com). In many aspects they are quite similar. However there can be singled out (marked out) the unexampled convenient interface for photo album managing in Spaces.msn.com. Though, from the other side the photo album pages’ addresses in this system looks like technical garbage and it is extremely difficult to exchange them. Evidently, Yahoo took into account that Microsoft experience and added an option to synchronize the photo albums with Flickr.com, the one of most popular system of photo album conducting for today.



Thus, if our purpose is to find new contacts based on the similar interests, we can achieve that soon and easy by means of above mentioned communities. In a case we are looking for the business contacts, the general interests’ communities of social networking barely can help us here. Among business oriented communities LinkedIn.Com was the one of the first, which has gained popularity. This project is popular today too. By means of this project you can create the detailed personal profile and then ask yours previous and current supervisors, colleagues, who participate in this network, to post their recommendation letters to every stage of your seniority (working experience). It will definitely help to gain a “bonus points” in time of getting prestigious business contacts. Any community is valuable by its content (essence, substance) first of all. The more there are potentially demanded by you community’s members (participants), the more valuable this community for you. On this point the professional community Ecademy.com should be mentioned. However, as we have to pay for quality, the full membership in Ecademy.com cost money. There is also a developing community Ziggs.com which is worthy of our attention. The Ziggs.com developers have focused on the idea to let the system’s users to present themselves and find the necessary contacts as easy as they find the documents by means of the search engine. As a result, there are more than 3 million registered professionals from more than 90 thousands companies in Ziggs.com today.



Several words should be devoted to Plaxo.com. This is a specific project, which has developed from the electronic “business card” service and it counts about 5 million business cards at present moment. There is a desk (hand) program within the project that expands the features of your email client’s interface. For example, you can get the automatic notifications from your friends about different events.



In a conclusion I would say the following. Do not expect that if you post a profile (even the interesting one!) in one of network communities, you will find a lot of new friends. In the Internet you should be as active as in the real life for finding friends. The mentioned projects will help you to find congenial souls or professionally close people. However it is your task to get their interest.


Data, its presentation and user interface forms


XML has acquired a distinguished popularity lately. No one doubts its perspectives of overall use. The concept of semantic web is no longer an abstraction and is implemented into life with confidence. In the world net's information cacophony there appears harmony. In the hands of talented conductors such as W3C, ISO, OASIS it can diversify into a symphony.


Today XML family has so many standards available that it seems there should be quite enough for all possible aspects of information technology world. It is generally so. But let's see how XML era has influenced ordinary web development tasks.


To deliver information to a user a site is needed. Web site content should be managed and that involves separation data from its presentation. The task is still often solved with the help of templates in program technologies. Though now we have XSLT technology at our disposal. Any document can be represented with data that is structured in detail with the help of XSL. It is quite enough to report the corresponding XSL template to define a proper graphic presentation for the data. XSL language is polymorphous and permits high flexibility in format changes of documents.

This might seem to be St.Grail of web development - we add XSL tools to our arsenal and shorten the time of the project development thus raising its quality.


However if we analyze time spent at creating a web project, it turns out that programming of user interfaces takes the most time. It is one thing to fill in the information, to deliver it to the user, and it is another thing to reconstruct multifunctional and easy to navigate interface. The tendency of content volume growth in the Internet is also worth mentioning here which makes effectiveness of user interfaces even more important.


XSL technology gives opportunities for managing document's presentation theoretically with any form of user interface. With its help the state of user interface can be analyzed and algorithms for data presentation be created depending on the conditions. But XSL operates XML data and it is necessary to prepare corresponding XML data file to assign an ordinary navigation menu in XSL.


In practice it turns out that XSLT template layers contain a mixture of user interface forms and presentation algorithms. Moreover the logics of user interface database forming is duplicated in CMS program code. How to avoid unnecessary program coding? How to achieve more visual presentation for user interface form algorithms?


In October 2004 Red Graphic Systems company published XML Sapiens specification. This technology aspires to take the place of a layer between XML and XSL. When XML Sapiens processor meets a link to a file with user interface forms' script, initial XML file is broaden with appropriate data. Let's suppose we want to form a vertical site menu page. We will need to create a script file (interface.sapi) and to describe a user interface form in it (DDC menu). We indicate that under any environment conditions we want to have reflection of the whole menu content. Using sapi:for-each construction, we can request any necessary data from CMS system function.


Then we manage enumeration of the data. We specify what exactly and in what cases should be returned within enumeration process. To send data dynamically formed by script to the initial XML-file we only need to arrange pointers. That means that after script file interface.sapi analysis XML Sapiens processor will broaden initial XML data file to the extent that is necessary for the following XSLT transformation.


Initial XML



<?xml version="1.0" encoding="UTF-8"?>
<?
xml-stylesheet type='text/xsl' href='template.xsl'?>
<?
xml-sapi type='text/xml' href='interface.sapi'?>
<
content xmlns:sapi="http://www.xmlsapiens.org/spec/sapi.dtd" xmlns:xlink="http://www.w3.org/1999/xlink">
    <data1>data1</data1>
    <data2>data2</data2>
  <menu><sapi:apply name="ddc.menu.value" /></menu>
  <title><sapi:apply name="qc.title.value"></title>
  <publication><sapi:apply name="qc.publication.value"></publication>
</
content> 


 XML Sapiens file script interface.sapi



<?xml version="1.0" encoding="UTF-8"?>
<
sapi version="1.0" xmlns:sapi="http://www.xmlsapiens.org/spec/sapi.dtd">
 <sapi:ddc name="menu">
 <sapi:choose>
  <sapi:when exp="TRUE"> 
  
<sapi:for-each select="get_tree()">
    <sapi:choose>
      <sapi:when exp="TRUE">
        <sapi:code>
          <row sapi:id="this.this.id.value" sapi:activity="this.this.currentpage.value">
                     <link><sapi:apply name="this.this.href.value" /></link>
            <item><sapi:apply name="this.this.title.value" /></item>
          </row>
        </sapi:code>
      </sapi:when>
    </sapi:choose>
   </sapi:for-each>
  </sapi:when>
 </sapi:choose>
 </sapi:ddc>
</
sapi> 


XML Sapiens script algorithm (interface.sapi)





XML Sapiens script algorithm (interface.sapi)



Final XML



<?xml version="1.0" encoding="UTF-8"?>
<?
xml-stylesheet type='text/xsl' href='template.xsl'?>
<
content xmlns:sapi="http://www.xmlsapiens.org/spec/sapi.dtd" xmlns:xlink="http://www.w3.org/1999/xlink">
    <data1>data1</data1>
    <data2>data2</data2>
    <menu>
     <row id="01" activity="1">
      <link>/intro/</link>
      <item>Introduction</item>
     </row>
     <row id="02" activity="0">
      <link>/chapter1/</link>
      <item>Chapter 1</item>
     </row>
     <row id="03" activity="0">
      <link>/chapter2/</link>
      <item>Chapter 2</item>
     </row>
    </menu>
    <title><![CDATA[Introduction]]></title>
    <publication><![CDATA[<p>Content</p>]]></publication>
</
content> 








It should be admitted that transfer of CMS instructions and receiving of the requested data from the script directly make web development process much easier. Such approach gives opportunity to disengage from the system language programming. Taking this into consideration the document content to be administered can be requested from CMS in XML Sapiens script directly. You just place the corresponding markers in the initial XML.

Displayed document formation chart


Displayed document formation chart

 



It is hard to predict XML Sapiens' perspectives now. Unlike above-mentioned XSL, it is not an approved W3C standard. Though the tasks covered by XML Sapiens specification such as separation of user interface form algorithms from data presentation, clearness and availability of algorithms descriptions, are quite up to date. This project might attract the attention of developers' community. That could result in appearance of new technologies able to increase the quality and profitability in web development.



Linked resources:

How to make own CMS

Every day millions of new web documents emerge on the Internet, and the amount of web management tools is growing simultaneously. These tools are usually referred to as Content Management Systems, CMS for short. If you have a web site and still do not use any CMS, you will definitely face a choice to buy or to develop an enterprise content management solution in the near future. What would you do if you wanted to develop a CMS, your own software that has a WYSIWYG editor and perfectly meets all your requirements and security standards? Can this task be fulfilled? Which ROI should you expect? You will have to answer all those questions all by yourself. Your chance to success can be increased if you gain an understanding of basics of a web content management system.


There are two models of any Content Management System. For visitors, the CMS displays web site content. Let us call it a site presentation mode. In admin mode a web master or a site administrator can update content and manage structure and templates. Here we speak about the insides of the website, i.e. the web site's admin mode.

Every page of the site is a web document that has its own address. The web site is a set of such hyperlinked documents. To make the web site user-friendly links to other documents and web services are displayed in various navigation bars and menus according to their logical interconnection. That is how the site structure is created. The document structure presupposes some categories of documents, identical by their logical architecture and presentation.

So, in admin mode the CMS presents the interface with categorized documents and the interface for document structure. The former will contain web document templates determining their logical architecture and presentation. The latter, structure interface, enables to update content and add, edit and delete documents, as well as set related pages. The way your CMS assigns the document structure of your web site is up to you. The simplest and the most common way is to make a hierarchical structure tree. We all saw it in site maps. However, we should keep in mind that the web site may require another language version in the future. Accordingly, the site will lie as the root, and language versions will be its branches.

The document structure interface allows managing web document attributes (name, URI, pointer to template, etc.). An attentive reader shall ask "And what about the document contents?"

As said above, the document template determines document presentation and its architecture. So, the document is not the data. In order to get some data and then put it as content into a web document, the system needs a template. As a result, a next interface for content query can be generated for example, name field, summary field, and WYSIWYG editor for the text body and image upload field.

It is clear that presentation can be done not only in HTML, but XML also. If you use XML in templates, you can manipulate Flash documents and update Flash sites.

This article can't cover all the questions that can arise during Content Management System's implementation. When assembling a programming core for your web solution, you should be certain to think of template pointers syntax and development of other Internet services and modules. However, XML Sapiens Specification gives a detailed explanation how it works. This XML Specification is available in English and Russian at www.XMLSapiens.org. To study the example of a web content management system visit http://sapid.sf.net, SAPID Open Source CMS available under GNU license. You can also use it to create your own web site, all for free.

XML Sapiens is a tool to divide site functionality and program core

Each minute the amount of content in the Web is surging up. This tendency is getting more and more intensive. As a result, tough competition makes web site-builders develop complicated interfaces to content. New generations of Content Management Systems (CMS) are replacing one another with impressive dynamics. Modern solutions require brand-new features, unavailable in the recent past. Tomorrow they' will need features, which are not available today. The question “How do I save my investment to web development?” is still open.

If to start analyzing CMS evolution you may notice that the bottleneck is fixed functionality tied to program core.?This is the same kind of limitation as with content and HTML being not separated before XML/XSL replaced HTML. XML/XSL replaced HTML and here was the way out. But what would solve problems related to site functionality inseparable of program core? May be it would be XML Sapiens?

Red Graphic Systems is presenting XML Sapiens, a specification for program interfaces of CMS-powered web sites. This specification outlines the concept with separated functionality and its presentation. It means that site interfaces are not attached to program core in systems complying with requirements of XML Sapiens. For example, to create a new interface you do not need to re-program you CMS, you only need to add a new interface description to XML Sapiens dictionary.

How does it work? In common way, while you request document URI, XML Sapiens environment variables are set. Depending on them the site engine requests the data and a presentation template from data depositary (for example, database). Both of them are delivered to XML Sapiens parser. It parses presentation template, analyzes objects of XML Sapiens and processes them according to the rules that are described in XML Sapiens Dictionary. For example, dynamic data containers are replaced with code, which was generated by algorithm based on model represented in this object description and environment arguments. Query containers in case of data delivery (displaying the page to a site visitor) are replaced with appropriate data they are pointing to. In case of site administration they are replaced with query forms, requesting this data.

Furthermore, XML Sapiens Specification provided here also describes the model of CMS, which is based on data arrays for information areas, including numerous sites and their language versions.

Hopefully, XML Sapiens helps develop CMS, which will be able to self-evolution and superstructure for the day after tomorrow.

XML Sapiens - the power to set you site alive!

Have you ever looked for an Open Source CMS for your site? Have you ever faced any problems while developing functional models? Most likely you thought “It would?be cool if there was a macro language to describe my site interfaces without any limitations to predefined stamps.” And you were definitely right!

In reality, there were numerous Content Management Systems, but there was no concept that describes CMS model as a whole and unifies functionality with the program core. Still, a concept like this really exists! It is described in XML Sapiens specification available here. XML Sapiens is an XML-oriented language for user interface description, developed and supported by Red Graphic Systems.

XML Sapiens treats any site or a family of web sites (multitude of sites and their language versions) in three dimensions: data, its presentation and functionality. In other words, any web document includes unique data, a presentation template and a functional model. In this way, while generating a web document the CMS parser analyzes it?s template for XML Sapiens objects. All query containers will be replaced with appropriate data from data depositary (for example, database).

During an admin session, these containers will be replaced with data query forms. Static data containers will be replaced with the appropriate code, attached to them. In the end, dynamic data containers will be replaced with a code, generated in compliance with their functional model.

As such, dynamic data containers are just tools for managing web site functionality.

But how does it all work? For example, we are planning to make a layout with a side menu on all pages according to template X. So we should define the XML Sapiens dynamic data container. A pointer to CMS application that returns a site structure array will be placed into this definition. Here we can also determine rules and styles for data presentation. And the last thing: we need to locate the pointer to our dynamic data container in template X. Just in the same way we are able to determine different navigation forms, interactive forms, information channels, etc. We can even configure a template and its containers to display web documents in XML format, which will be understood by Flash application, Java applet, WAP browser or SVG.

So why should you limit your creative ideas and development? Use XML Sapiens and you are a success!

The Essence of a Managed Web Site

Lets imagine that we are developing a new content management system or simply CMS. What shall we think of first?

» CMS should support all the interfaces stipulated in the technical specifications for the site construction
» CMS-powered web site should comply with general requirements to design, usability and information architecture.
» CMS should successfully run all tasks related to web site authoring.

However the task is getting more complicated when there is a family of web sites to maintain and support. Or if there are no technical specs available at all. Obviously, there should be some pattern for managing similar web sites. The problem is, that traditional API approaches do not fit here well. Every new web site needs to be different from others. The more significant the difference is the better. Accordingly, interface standardization of any kind seems to be a failure. Still, Red Graphic Systems can offer its intelligible solution, namely XML Sapiens.

XML Sapiens is a simple language for describing programming interfaces of CMS-powered web sites. XML Sapiens was designed by Red Graphic Systems in 2003 for Site SapiensTM, the corporate web area management platform. In 2004 Red Graphic Systems made it public on www.xmlsapiens.org. The concept of XML Sapiens is based on the three components necessary for creation of any web document:

» Content
» Presentation
» Functionality.

All of them are united with one object model, based on:

Query containers assign a document representation model in the data presentation template; they also report to the admin area how the data will be inquired from a user.

Static data containers support elements of code (HTML, XML, etc.) and retrieve this code in the data representation template.

Dynamic data containers cover a logically bound part of a web document, the content of which will be generated by CMS according to the special scenario. Dynamic data containers of XML

Sapiens allow to simply yet efficiently describe any functionality for the managed web site; and to create a new user interface quickly and easily.

So, XML Sapiens defines and unifies structure of CMS-powered web sites. Furthermore, it differentiates web site functionality from its presentation and content. Our project www.xmlsapiens.org seems to be the only service in the Internet that allows exchange of cross-platform functional solutions for CMS-powered web sites for developers and project managers.

The total volume of copy in the Web is shooting up each day. Hopefully, technologies like XML Sapiens will consolidate the efforts of CMS developers allowing to bring the content management under control.