Aspectj application-new method of software productization

Source: Internet
Author: User

Author: Anders James

The two words productization and customization are a pair of twins. A software without powerful customization capabilities cannot be called productization software. productization means that software company development should be divided into at least two different roles: one responsible for productization and the other responsible for customization. aside from traditional parameterization, inheritance, and plugin technologies, aspectj provides us with another capability.

As mentioned above, the company has two teams with different roles in development and maintenance-R & D group and project group. Further, this article will adapt to the following development team structure:
One R & D group-multiple project teams, each of which requires different customization items. to ensure the relative independence of several teams, the company hopes that the project team will not change the code developed by the R & D team during the customization process, and apply the known method: parameterization, inheritance and plug-in technology.

However, these technologies do not cover all problems. The problem is described as follows:

After analysis, we found that a propertya needs to be added to the root class. In this case, based on the existing capabilities, we can choose either Project Team A is modifying the root class, either modify each leaf class (leafa ....), obviously, modifying the root class is a good choice. however, project team B needs to add another properyb, so Project Team B does the same. this is not a problem for Project Team A and Team B.
However, the problem with the R & D group is very serious. Because the R & D group needs to reclaim code from the project to improve the software by absorbing advantages, the R & D group has to carefully maintain each version, and process the modifications made by the project team. at the same time, the project team obtained the right to modify the code of the R & D group. At the time pressure, code that does not comply with the system structure constraints will be generated.
Obviously, this kind of work method is not good for our work. We need a new idea.

Before formally proposing a new method, I would like to introduce Microsoft's DSL tools and C #2.0 first. Thank you for your patience.
DSL tools is a domain specification language developed by Microsoft. It aims to describe business problems with a language model closer to the business and generate Running code. The tool allows users to define their respective domain languages, with the target being a software factory. DSL tools faces a problem (which is also currently faced by the company). The defined DSL and generated code inevitably have minor differences between different customers. dsl tools must solve it well, in fact, DSL tools does. It is based on the C #2.0 partial class technology. (For more information about DSL tools, see msdn ).
In short, partial class is actually the structure information of a class that can be stored in multiple files. The following is an example:
 
File1.cs (a Microsoft file can define multiple classes, and all file names do not need similar names ):
Public partial class cagent {
Private string name;
Property string name {
Get {
Return name;
}
Set {
This. Name = Name;
}
}
Public void dosomethinga (){
....
}
}
 
File2.cs
Public partial class cagent {
Private string code;
Property string code {
Get {
Return code;
}
Set {
This. Code = code;
}
}
Public void dosomethingb (){
....
}
}
Although the cagent class is divided into two files, for the caller class, the specific name and code of the cagent are two properties, and dosomethinga and dosomethingb methods.
Now you can imagine how DSL tools solves the problem of customization!
All the classes generated by DSL tools are partial classes. When cagent (or other classes) needs to be customized, you only need to add a new file, add a partial keyword to the same class name,
Public partial class cagent can be used to add new attributes and methods (as I have shown, imagine that file1.cs is R & D and maintenance, while file2.cs is project maintenance ). That is to say, the dsl r & D team and the customer team work relatively independently.
 
Then you will surely say that Microsoft's C #, unfortunately, the company uses Java, and the Java language specification does not support such capabilities.
Yes, you are right. Java itself is not supported, but we have such a method-aspectj.
In fact, aspectj has been around for a long time. I have been in touch with it for at least a year and a half, but I have never thought of it until I have studied DSL tools (I believe many of the principles are the same, we are currently faced with the same problems as those in Silicon Valley)
The following is a simple example:
ONTYPE. Java:
Public class ONTYPE {
Public void doaction (){
System. Out. println ("ONTYPE. doaction ");
}
}
 
Ontypeaspect. AJ
Public aspect ontypeaspect {
Public String ONTYPE. Name = "ontypeaspect ";
 
Public void ONTYPE. doactionaspect (){
System. Out. println ("ONTYPE. doactionaspect and name is" + name );
}
}
 
Main2.aj
Public class main2 {
Public static void main (string [] ARGs ){
ONTYPE = new ONTYPE ();
ONTYPE. doactionaspect ();
}
}
 
As you can see, the program can run completely. Your console has played: ONTYPE. doactionaspect and name is ontypeaspect
In addition, aspectj can add new interfaces for existing classes, just as the partial class of C # does.
 
I think aspectj is a shortcut to achieve our goal, and it has been practiced. I don't believe that aspectj and Microsoft will be idle to support such technology. BTW, I heard that Weblogic's jrockit is ready to support aspectj at the VM level, so maybe the rest of the work is how to manage and use aspectj.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.