<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Vdiyer</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Vdiyer"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Vdiyer"/>
	<updated>2026-06-07T00:31:28Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24649</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24649"/>
		<updated>2009-10-09T22:37:12Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* Terminologies used in Aspect Oriented Programming */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.'''Cross-cutting concerns''':(For a definition, go to [[http://en.wikipedia.org/wiki/Cross-cutting_concern Appendix 3]].) Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.'''Advice''': Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.'''Point-cut''': Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.'''Aspect''': Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC. For a better definition, go to [[http://en.wikipedia.org/wiki/AspectJ Appendix 1]]&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ. For a clearer definition, go to [[http://eclipse.org/ajdt/ Appendix 2]].&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
== AspectR == &lt;br /&gt;
&lt;br /&gt;
Aspect-oriented programming concepts to Ruby is provided by AspectR. Inside the classes, existing methods can be wrapped around by code using AspectR.The design of the code can be improved since it separates different concerns into different parts of the code. It is similar to AspectJ. [[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Main features of AspectR: &lt;br /&gt;
&lt;br /&gt;
•       Join points&lt;br /&gt;
&lt;br /&gt;
•	Object receives method/constructor call &lt;br /&gt;
&lt;br /&gt;
•	Field accessed (if access is via getter/setter method)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advices can access:&lt;br /&gt;
&lt;br /&gt;
•	Object and method receiving call&lt;br /&gt;
&lt;br /&gt;
•	Arguments to call&lt;br /&gt;
&lt;br /&gt;
•	Return value&lt;br /&gt;
&lt;br /&gt;
•	exceptions raised&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aspects: &lt;br /&gt;
&lt;br /&gt;
•	Supports &amp;quot;abstract&amp;quot; Aspects and overriding between advices.&lt;br /&gt;
&lt;br /&gt;
•	Wildcards (really regexps) can be used in pointcut designators, ie. to specify classes and methods to wrap advices to&lt;br /&gt;
&lt;br /&gt;
•	Pointcut parameters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AspectR lets a module wrap any number of methods in other classes (or objects) with the &amp;quot;advice&amp;quot; methods (in the lingo of Aspect/J) of the module.&lt;br /&gt;
&lt;br /&gt;
        source: http://aspectr.sourceforge.net/&lt;br /&gt;
        require 'aspectr'&lt;br /&gt;
        include AspectR&lt;br /&gt;
        class MyAspect &amp;lt; Aspect&lt;br /&gt;
        def someAdviceMethod(method, object, exitstatus, *args)&lt;br /&gt;
             ...&lt;br /&gt;
        end&lt;br /&gt;
        ... some other advice methods ...&lt;br /&gt;
        end&lt;br /&gt;
        ma = MyAspect.new&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, ... methods to wrap...) or&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, /patternToWrap/) or&lt;br /&gt;
        AspectR.wrap_classes(ma, :preAdvice, :postAdvice,&lt;br /&gt;
       [Class1, Class2], ...methods to wrap...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advice methods are passed a variable number of parameters: the first is the name of the method currently being wrapped the second is the object receiving the method call the third is the exit/return status:&lt;br /&gt;
&lt;br /&gt;
        source:http://aspectr.sourceforge.net/&lt;br /&gt;
        Array with return value(s) if the method exited normally&lt;br /&gt;
        true if the method exited with an exception&lt;br /&gt;
        nil if the method hasn't yet exited (for preAdvice)&lt;br /&gt;
the rest are the arguments that were passed to the wrapped method.[[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquarium is a framework that implements Aspect-Oriented Programming (AOP) for Ruby.&lt;br /&gt;
Aquarium provides a Domain Specific Language (DSL) with which you can express “aspectual” system behaviour in a modular way, i.e.,using a succinct language and without repeating yourself all over your code base.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
Imagine you want to trace all invocations of the public, instance methods in all classes whose names end with “Service”. Here’s how you can implement that behavior in Aquarium:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL before :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args log &amp;quot;Entering:    &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 after :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|log &amp;quot;Leaving:              &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The #before advice adds behavior that is invoked before each method is invoked, in this case, it logs a message with the name of the executing class and method, followed by the list of arguments passed to the method.&lt;br /&gt;
The #after advice adds similar behavior the is invoked after each method is invoked.&lt;br /&gt;
&lt;br /&gt;
A more succinct implementation of this behavior uses #around advice:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL around :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args| log &amp;quot;Entering: &lt;br /&gt;
 {join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result = join_point.proceed&lt;br /&gt;
 log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result  # block needs to return the result of the &amp;quot;proceed&amp;quot;!&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The special method #proceed invokes the advised method, passing it the args list (by default). For #around advice, you must call#proceed unless you specifically don’t want the original method called.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
'''1'''. AspectJ is an aspect-oriented extension created at PARC for the Java programming language. It is available in Eclipse Foundation   open-source projects, both stand-alone and integrated into Eclipse. For more information refer to: http://en.wikipedia.org/wiki/AspectJ&lt;br /&gt;
&lt;br /&gt;
'''2'''. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
'''3'''. cross cutting concerns - http://en.wikipedia.org/wiki/Cross-cutting_concern&lt;br /&gt;
&lt;br /&gt;
== References &amp;amp; Resources ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;br /&gt;
&lt;br /&gt;
[4]http://rubyforge.org/projects/aquarium/&lt;br /&gt;
&lt;br /&gt;
[5]http://aspectr.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
[6]http://aquarium.rubyforge.org/examples.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24642</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24642"/>
		<updated>2009-10-09T22:33:25Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* Terminologies used in Aspect Oriented Programming */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns:(For a definition, go to [[http://en.wikipedia.org/wiki/Cross-cutting_concern Appendix 3]].) Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC. For a better definition, go to [[http://en.wikipedia.org/wiki/AspectJ Appendix 1]]&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ. For a clearer definition, go to [[http://eclipse.org/ajdt/ Appendix 2]].&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
== AspectR == &lt;br /&gt;
&lt;br /&gt;
Aspect-oriented programming concepts to Ruby is provided by AspectR. Inside the classes, existing methods can be wrapped around by code using AspectR.The design of the code can be improved since it separates different concerns into different parts of the code. It is similar to AspectJ. [[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Main features of AspectR: &lt;br /&gt;
&lt;br /&gt;
•       Join points&lt;br /&gt;
&lt;br /&gt;
•	Object receives method/constructor call &lt;br /&gt;
&lt;br /&gt;
•	Field accessed (if access is via getter/setter method)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advices can access:&lt;br /&gt;
&lt;br /&gt;
•	Object and method receiving call&lt;br /&gt;
&lt;br /&gt;
•	Arguments to call&lt;br /&gt;
&lt;br /&gt;
•	Return value&lt;br /&gt;
&lt;br /&gt;
•	exceptions raised&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aspects: &lt;br /&gt;
&lt;br /&gt;
•	Supports &amp;quot;abstract&amp;quot; Aspects and overriding between advices.&lt;br /&gt;
&lt;br /&gt;
•	Wildcards (really regexps) can be used in pointcut designators, ie. to specify classes and methods to wrap advices to&lt;br /&gt;
&lt;br /&gt;
•	Pointcut parameters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AspectR lets a module wrap any number of methods in other classes (or objects) with the &amp;quot;advice&amp;quot; methods (in the lingo of Aspect/J) of the module.&lt;br /&gt;
&lt;br /&gt;
        source: http://aspectr.sourceforge.net/&lt;br /&gt;
        require 'aspectr'&lt;br /&gt;
        include AspectR&lt;br /&gt;
        class MyAspect &amp;lt; Aspect&lt;br /&gt;
        def someAdviceMethod(method, object, exitstatus, *args)&lt;br /&gt;
             ...&lt;br /&gt;
        end&lt;br /&gt;
        ... some other advice methods ...&lt;br /&gt;
        end&lt;br /&gt;
        ma = MyAspect.new&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, ... methods to wrap...) or&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, /patternToWrap/) or&lt;br /&gt;
        AspectR.wrap_classes(ma, :preAdvice, :postAdvice,&lt;br /&gt;
       [Class1, Class2], ...methods to wrap...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advice methods are passed a variable number of parameters: the first is the name of the method currently being wrapped the second is the object receiving the method call the third is the exit/return status:&lt;br /&gt;
&lt;br /&gt;
        source:http://aspectr.sourceforge.net/&lt;br /&gt;
        Array with return value(s) if the method exited normally&lt;br /&gt;
        true if the method exited with an exception&lt;br /&gt;
        nil if the method hasn't yet exited (for preAdvice)&lt;br /&gt;
the rest are the arguments that were passed to the wrapped method.[[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquarium is a framework that implements Aspect-Oriented Programming (AOP) for Ruby.&lt;br /&gt;
Aquarium provides a Domain Specific Language (DSL) with which you can express “aspectual” system behaviour in a modular way, i.e.,using a succinct language and without repeating yourself all over your code base.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
Imagine you want to trace all invocations of the public, instance methods in all classes whose names end with “Service”. Here’s how you can implement that behavior in Aquarium:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL before :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args log &amp;quot;Entering:    &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 after :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|log &amp;quot;Leaving:              &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The #before advice adds behavior that is invoked before each method is invoked, in this case, it logs a message with the name of the executing class and method, followed by the list of arguments passed to the method.&lt;br /&gt;
The #after advice adds similar behavior the is invoked after each method is invoked.&lt;br /&gt;
&lt;br /&gt;
A more succinct implementation of this behavior uses #around advice:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL around :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args| log &amp;quot;Entering: &lt;br /&gt;
 {join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result = join_point.proceed&lt;br /&gt;
 log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result  # block needs to return the result of the &amp;quot;proceed&amp;quot;!&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The special method #proceed invokes the advised method, passing it the args list (by default). For #around advice, you must call#proceed unless you specifically don’t want the original method called.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
'''1'''. AspectJ is an aspect-oriented extension created at PARC for the Java programming language. It is available in Eclipse Foundation   open-source projects, both stand-alone and integrated into Eclipse. For more information refer to: http://en.wikipedia.org/wiki/AspectJ&lt;br /&gt;
&lt;br /&gt;
'''2'''. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
'''3'''. cross cutting concerns - http://en.wikipedia.org/wiki/Cross-cutting_concern&lt;br /&gt;
&lt;br /&gt;
== References &amp;amp; Resources ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;br /&gt;
&lt;br /&gt;
[4]http://rubyforge.org/projects/aquarium/&lt;br /&gt;
&lt;br /&gt;
[5]http://aspectr.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
[6]http://aquarium.rubyforge.org/examples.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24635</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24635"/>
		<updated>2009-10-09T22:32:15Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* Appendix */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns:[[http://en.wikipedia.org/wiki/Cross-cutting_concern Appendix 3]] Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC. For a better definition, go to [[http://en.wikipedia.org/wiki/AspectJ Appendix 1]]&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ. For a clearer definition, go to [[http://eclipse.org/ajdt/ Appendix 2]].&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
== AspectR == &lt;br /&gt;
&lt;br /&gt;
Aspect-oriented programming concepts to Ruby is provided by AspectR. Essentially it allows you to wrap code around existing methods in your classes. This can be a good thing (and even affect how you design your code) since it separates different concerns into different parts of the code. It is somewhat similar to AspectJ. [[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Main features of AspectR: &lt;br /&gt;
&lt;br /&gt;
•       Join points&lt;br /&gt;
&lt;br /&gt;
•	Object receives method/constructor call &lt;br /&gt;
&lt;br /&gt;
•	Field accessed (if access is via getter/setter method)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advices can access:&lt;br /&gt;
&lt;br /&gt;
•	Object and method receiving call&lt;br /&gt;
&lt;br /&gt;
•	Arguments to call&lt;br /&gt;
&lt;br /&gt;
•	Return value&lt;br /&gt;
&lt;br /&gt;
•	exceptions raised&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aspects: &lt;br /&gt;
&lt;br /&gt;
•	Supports &amp;quot;abstract&amp;quot; Aspects and overriding between advices.&lt;br /&gt;
&lt;br /&gt;
•	Wildcards (really regexps) can be used in pointcut designators, ie. to specify classes and methods to wrap advices to&lt;br /&gt;
&lt;br /&gt;
•	Pointcut parameters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AspectR lets a module wrap any number of methods in other classes (or objects) with the &amp;quot;advice&amp;quot; methods (in the lingo of Aspect/J) of the module.&lt;br /&gt;
&lt;br /&gt;
        source: http://aspectr.sourceforge.net/&lt;br /&gt;
        require 'aspectr'&lt;br /&gt;
        include AspectR&lt;br /&gt;
        class MyAspect &amp;lt; Aspect&lt;br /&gt;
        def someAdviceMethod(method, object, exitstatus, *args)&lt;br /&gt;
             ...&lt;br /&gt;
        end&lt;br /&gt;
        ... some other advice methods ...&lt;br /&gt;
        end&lt;br /&gt;
        ma = MyAspect.new&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, ... methods to wrap...) or&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, /patternToWrap/) or&lt;br /&gt;
        AspectR.wrap_classes(ma, :preAdvice, :postAdvice,&lt;br /&gt;
       [Class1, Class2], ...methods to wrap...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advice methods are passed a variable number of parameters: the first is the name of the method currently being wrapped the second is the object receiving the method call the third is the exit/return status:&lt;br /&gt;
&lt;br /&gt;
        source:http://aspectr.sourceforge.net/&lt;br /&gt;
        Array with return value(s) if the method exited normally&lt;br /&gt;
        true if the method exited with an exception&lt;br /&gt;
        nil if the method hasn't yet exited (for preAdvice)&lt;br /&gt;
the rest are the arguments that were passed to the wrapped method.[[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquarium is a framework that implements Aspect-Oriented Programming (AOP) for Ruby.&lt;br /&gt;
Aquarium provides a Domain Specific Language (DSL) with which you can express “aspectual” system behaviour in a modular way, i.e.,using a succinct language and without repeating yourself all over your code base.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
Imagine you want to trace all invocations of the public, instance methods in all classes whose names end with “Service”. Here’s how you can implement that behavior in Aquarium:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL before :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args log &amp;quot;Entering:    &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 after :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|log &amp;quot;Leaving:              &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The #before advice adds behavior that is invoked before each method is invoked, in this case, it logs a message with the name of the executing class and method, followed by the list of arguments passed to the method.&lt;br /&gt;
The #after advice adds similar behavior the is invoked after each method is invoked.&lt;br /&gt;
&lt;br /&gt;
A more succinct implementation of this behavior uses #around advice:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL around :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args| log &amp;quot;Entering: &lt;br /&gt;
 {join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result = join_point.proceed&lt;br /&gt;
 log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result  # block needs to return the result of the &amp;quot;proceed&amp;quot;!&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The special method #proceed invokes the advised method, passing it the args list (by default). For #around advice, you must call#proceed unless you specifically don’t want the original method called.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
'''1'''. AspectJ is an aspect-oriented extension created at PARC for the Java programming language. It is available in Eclipse Foundation   open-source projects, both stand-alone and integrated into Eclipse. For more information refer to: http://en.wikipedia.org/wiki/AspectJ&lt;br /&gt;
&lt;br /&gt;
'''2'''. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
'''3'''. cross cutting concerns - http://en.wikipedia.org/wiki/Cross-cutting_concern&lt;br /&gt;
&lt;br /&gt;
== References &amp;amp; Resources ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;br /&gt;
&lt;br /&gt;
[4]http://rubyforge.org/projects/aquarium/&lt;br /&gt;
&lt;br /&gt;
[5]http://aspectr.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
[6]http://aquarium.rubyforge.org/examples.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24632</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24632"/>
		<updated>2009-10-09T22:31:31Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* Terminologies used in Aspect Oriented Programming */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns:[[http://en.wikipedia.org/wiki/Cross-cutting_concern Appendix 3]] Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC. For a better definition, go to [[http://en.wikipedia.org/wiki/AspectJ Appendix 1]]&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ. For a clearer definition, go to [[http://eclipse.org/ajdt/ Appendix 2]].&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
== AspectR == &lt;br /&gt;
&lt;br /&gt;
Aspect-oriented programming concepts to Ruby is provided by AspectR. Essentially it allows you to wrap code around existing methods in your classes. This can be a good thing (and even affect how you design your code) since it separates different concerns into different parts of the code. It is somewhat similar to AspectJ. [[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Main features of AspectR: &lt;br /&gt;
&lt;br /&gt;
•       Join points&lt;br /&gt;
&lt;br /&gt;
•	Object receives method/constructor call &lt;br /&gt;
&lt;br /&gt;
•	Field accessed (if access is via getter/setter method)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advices can access:&lt;br /&gt;
&lt;br /&gt;
•	Object and method receiving call&lt;br /&gt;
&lt;br /&gt;
•	Arguments to call&lt;br /&gt;
&lt;br /&gt;
•	Return value&lt;br /&gt;
&lt;br /&gt;
•	exceptions raised&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aspects: &lt;br /&gt;
&lt;br /&gt;
•	Supports &amp;quot;abstract&amp;quot; Aspects and overriding between advices.&lt;br /&gt;
&lt;br /&gt;
•	Wildcards (really regexps) can be used in pointcut designators, ie. to specify classes and methods to wrap advices to&lt;br /&gt;
&lt;br /&gt;
•	Pointcut parameters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AspectR lets a module wrap any number of methods in other classes (or objects) with the &amp;quot;advice&amp;quot; methods (in the lingo of Aspect/J) of the module.&lt;br /&gt;
&lt;br /&gt;
        source: http://aspectr.sourceforge.net/&lt;br /&gt;
        require 'aspectr'&lt;br /&gt;
        include AspectR&lt;br /&gt;
        class MyAspect &amp;lt; Aspect&lt;br /&gt;
        def someAdviceMethod(method, object, exitstatus, *args)&lt;br /&gt;
             ...&lt;br /&gt;
        end&lt;br /&gt;
        ... some other advice methods ...&lt;br /&gt;
        end&lt;br /&gt;
        ma = MyAspect.new&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, ... methods to wrap...) or&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, /patternToWrap/) or&lt;br /&gt;
        AspectR.wrap_classes(ma, :preAdvice, :postAdvice,&lt;br /&gt;
       [Class1, Class2], ...methods to wrap...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advice methods are passed a variable number of parameters: the first is the name of the method currently being wrapped the second is the object receiving the method call the third is the exit/return status:&lt;br /&gt;
&lt;br /&gt;
        source:http://aspectr.sourceforge.net/&lt;br /&gt;
        Array with return value(s) if the method exited normally&lt;br /&gt;
        true if the method exited with an exception&lt;br /&gt;
        nil if the method hasn't yet exited (for preAdvice)&lt;br /&gt;
the rest are the arguments that were passed to the wrapped method.[[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquarium is a framework that implements Aspect-Oriented Programming (AOP) for Ruby.&lt;br /&gt;
Aquarium provides a Domain Specific Language (DSL) with which you can express “aspectual” system behaviour in a modular way, i.e.,using a succinct language and without repeating yourself all over your code base.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
Imagine you want to trace all invocations of the public, instance methods in all classes whose names end with “Service”. Here’s how you can implement that behavior in Aquarium:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL before :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args log &amp;quot;Entering:    &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 after :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|log &amp;quot;Leaving:              &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The #before advice adds behavior that is invoked before each method is invoked, in this case, it logs a message with the name of the executing class and method, followed by the list of arguments passed to the method.&lt;br /&gt;
The #after advice adds similar behavior the is invoked after each method is invoked.&lt;br /&gt;
&lt;br /&gt;
A more succinct implementation of this behavior uses #around advice:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL around :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args| log &amp;quot;Entering: &lt;br /&gt;
 {join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result = join_point.proceed&lt;br /&gt;
 log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result  # block needs to return the result of the &amp;quot;proceed&amp;quot;!&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The special method #proceed invokes the advised method, passing it the args list (by default). For #around advice, you must call#proceed unless you specifically don’t want the original method called.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
'''1'''. AspectJ is an aspect-oriented extension created at PARC for the Java programming language. It is available in Eclipse Foundation   open-source projects, both stand-alone and integrated into Eclipse. For more information refer to: http://en.wikipedia.org/wiki/AspectJ&lt;br /&gt;
&lt;br /&gt;
'''2'''. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
== References &amp;amp; Resources ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;br /&gt;
&lt;br /&gt;
[4]http://rubyforge.org/projects/aquarium/&lt;br /&gt;
&lt;br /&gt;
[5]http://aspectr.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
[6]http://aquarium.rubyforge.org/examples.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24631</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24631"/>
		<updated>2009-10-09T22:29:20Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* Appendix */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC. For a better definition, go to [[http://en.wikipedia.org/wiki/AspectJ Appendix 1]]&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ. For a clearer definition, go to [[http://eclipse.org/ajdt/ Appendix 2]].&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
== AspectR == &lt;br /&gt;
&lt;br /&gt;
Aspect-oriented programming concepts to Ruby is provided by AspectR. Essentially it allows you to wrap code around existing methods in your classes. This can be a good thing (and even affect how you design your code) since it separates different concerns into different parts of the code. It is somewhat similar to AspectJ. [[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Main features of AspectR: &lt;br /&gt;
&lt;br /&gt;
•       Join points&lt;br /&gt;
&lt;br /&gt;
•	Object receives method/constructor call &lt;br /&gt;
&lt;br /&gt;
•	Field accessed (if access is via getter/setter method)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advices can access:&lt;br /&gt;
&lt;br /&gt;
•	Object and method receiving call&lt;br /&gt;
&lt;br /&gt;
•	Arguments to call&lt;br /&gt;
&lt;br /&gt;
•	Return value&lt;br /&gt;
&lt;br /&gt;
•	exceptions raised&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aspects: &lt;br /&gt;
&lt;br /&gt;
•	Supports &amp;quot;abstract&amp;quot; Aspects and overriding between advices.&lt;br /&gt;
&lt;br /&gt;
•	Wildcards (really regexps) can be used in pointcut designators, ie. to specify classes and methods to wrap advices to&lt;br /&gt;
&lt;br /&gt;
•	Pointcut parameters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AspectR lets a module wrap any number of methods in other classes (or objects) with the &amp;quot;advice&amp;quot; methods (in the lingo of Aspect/J) of the module.&lt;br /&gt;
&lt;br /&gt;
        source: http://aspectr.sourceforge.net/&lt;br /&gt;
        require 'aspectr'&lt;br /&gt;
        include AspectR&lt;br /&gt;
        class MyAspect &amp;lt; Aspect&lt;br /&gt;
        def someAdviceMethod(method, object, exitstatus, *args)&lt;br /&gt;
             ...&lt;br /&gt;
        end&lt;br /&gt;
        ... some other advice methods ...&lt;br /&gt;
        end&lt;br /&gt;
        ma = MyAspect.new&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, ... methods to wrap...) or&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, /patternToWrap/) or&lt;br /&gt;
        AspectR.wrap_classes(ma, :preAdvice, :postAdvice,&lt;br /&gt;
       [Class1, Class2], ...methods to wrap...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advice methods are passed a variable number of parameters: the first is the name of the method currently being wrapped the second is the object receiving the method call the third is the exit/return status:&lt;br /&gt;
&lt;br /&gt;
        source:http://aspectr.sourceforge.net/&lt;br /&gt;
        Array with return value(s) if the method exited normally&lt;br /&gt;
        true if the method exited with an exception&lt;br /&gt;
        nil if the method hasn't yet exited (for preAdvice)&lt;br /&gt;
the rest are the arguments that were passed to the wrapped method.[[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquarium is a framework that implements Aspect-Oriented Programming (AOP) for Ruby.&lt;br /&gt;
Aquarium provides a Domain Specific Language (DSL) with which you can express “aspectual” system behaviour in a modular way, i.e.,using a succinct language and without repeating yourself all over your code base.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
Imagine you want to trace all invocations of the public, instance methods in all classes whose names end with “Service”. Here’s how you can implement that behavior in Aquarium:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL before :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args log &amp;quot;Entering:    &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 after :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|log &amp;quot;Leaving:              &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The #before advice adds behavior that is invoked before each method is invoked, in this case, it logs a message with the name of the executing class and method, followed by the list of arguments passed to the method.&lt;br /&gt;
The #after advice adds similar behavior the is invoked after each method is invoked.&lt;br /&gt;
&lt;br /&gt;
A more succinct implementation of this behavior uses #around advice:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL around :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args| log &amp;quot;Entering: &lt;br /&gt;
 {join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result = join_point.proceed&lt;br /&gt;
 log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result  # block needs to return the result of the &amp;quot;proceed&amp;quot;!&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The special method #proceed invokes the advised method, passing it the args list (by default). For #around advice, you must call#proceed unless you specifically don’t want the original method called.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
'''1'''. AspectJ is an aspect-oriented extension created at PARC for the Java programming language. It is available in Eclipse Foundation   open-source projects, both stand-alone and integrated into Eclipse. For more information refer to: http://en.wikipedia.org/wiki/AspectJ&lt;br /&gt;
&lt;br /&gt;
'''2'''. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
== References &amp;amp; Resources ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;br /&gt;
&lt;br /&gt;
[4]http://rubyforge.org/projects/aquarium/&lt;br /&gt;
&lt;br /&gt;
[5]http://aspectr.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
[6]http://aquarium.rubyforge.org/examples.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24630</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24630"/>
		<updated>2009-10-09T22:29:02Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* AspectR */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC. For a better definition, go to [[http://en.wikipedia.org/wiki/AspectJ Appendix 1]]&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ. For a clearer definition, go to [[http://eclipse.org/ajdt/ Appendix 2]].&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
== AspectR == &lt;br /&gt;
&lt;br /&gt;
Aspect-oriented programming concepts to Ruby is provided by AspectR. Essentially it allows you to wrap code around existing methods in your classes. This can be a good thing (and even affect how you design your code) since it separates different concerns into different parts of the code. It is somewhat similar to AspectJ. [[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Main features of AspectR: &lt;br /&gt;
&lt;br /&gt;
•       Join points&lt;br /&gt;
&lt;br /&gt;
•	Object receives method/constructor call &lt;br /&gt;
&lt;br /&gt;
•	Field accessed (if access is via getter/setter method)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advices can access:&lt;br /&gt;
&lt;br /&gt;
•	Object and method receiving call&lt;br /&gt;
&lt;br /&gt;
•	Arguments to call&lt;br /&gt;
&lt;br /&gt;
•	Return value&lt;br /&gt;
&lt;br /&gt;
•	exceptions raised&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aspects: &lt;br /&gt;
&lt;br /&gt;
•	Supports &amp;quot;abstract&amp;quot; Aspects and overriding between advices.&lt;br /&gt;
&lt;br /&gt;
•	Wildcards (really regexps) can be used in pointcut designators, ie. to specify classes and methods to wrap advices to&lt;br /&gt;
&lt;br /&gt;
•	Pointcut parameters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AspectR lets a module wrap any number of methods in other classes (or objects) with the &amp;quot;advice&amp;quot; methods (in the lingo of Aspect/J) of the module.&lt;br /&gt;
&lt;br /&gt;
        source: http://aspectr.sourceforge.net/&lt;br /&gt;
        require 'aspectr'&lt;br /&gt;
        include AspectR&lt;br /&gt;
        class MyAspect &amp;lt; Aspect&lt;br /&gt;
        def someAdviceMethod(method, object, exitstatus, *args)&lt;br /&gt;
             ...&lt;br /&gt;
        end&lt;br /&gt;
        ... some other advice methods ...&lt;br /&gt;
        end&lt;br /&gt;
        ma = MyAspect.new&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, ... methods to wrap...) or&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, /patternToWrap/) or&lt;br /&gt;
        AspectR.wrap_classes(ma, :preAdvice, :postAdvice,&lt;br /&gt;
       [Class1, Class2], ...methods to wrap...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advice methods are passed a variable number of parameters: the first is the name of the method currently being wrapped the second is the object receiving the method call the third is the exit/return status:&lt;br /&gt;
&lt;br /&gt;
        source:http://aspectr.sourceforge.net/&lt;br /&gt;
        Array with return value(s) if the method exited normally&lt;br /&gt;
        true if the method exited with an exception&lt;br /&gt;
        nil if the method hasn't yet exited (for preAdvice)&lt;br /&gt;
the rest are the arguments that were passed to the wrapped method.[[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquarium is a framework that implements Aspect-Oriented Programming (AOP) for Ruby.&lt;br /&gt;
Aquarium provides a Domain Specific Language (DSL) with which you can express “aspectual” system behaviour in a modular way, i.e.,using a succinct language and without repeating yourself all over your code base.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
Imagine you want to trace all invocations of the public, instance methods in all classes whose names end with “Service”. Here’s how you can implement that behavior in Aquarium:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL before :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args log &amp;quot;Entering:    &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 after :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|log &amp;quot;Leaving:              &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The #before advice adds behavior that is invoked before each method is invoked, in this case, it logs a message with the name of the executing class and method, followed by the list of arguments passed to the method.&lt;br /&gt;
The #after advice adds similar behavior the is invoked after each method is invoked.&lt;br /&gt;
&lt;br /&gt;
A more succinct implementation of this behavior uses #around advice:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL around :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args| log &amp;quot;Entering: &lt;br /&gt;
 {join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result = join_point.proceed&lt;br /&gt;
 log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result  # block needs to return the result of the &amp;quot;proceed&amp;quot;!&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The special method #proceed invokes the advised method, passing it the args list (by default). For #around advice, you must call#proceed unless you specifically don’t want the original method called.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
'''1'''. AspectJ is an aspect-oriented extension created at PARC for the Java programming language. It is available in Eclipse Foundation   open-source projects, both stand-alone and integrated into Eclipse. For more information refer to: http://en.wikipedia.org/wiki/AspectJ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''2'''. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
== References &amp;amp; Resources ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;br /&gt;
&lt;br /&gt;
[4]http://rubyforge.org/projects/aquarium/&lt;br /&gt;
&lt;br /&gt;
[5]http://aspectr.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
[6]http://aquarium.rubyforge.org/examples.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24626</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24626"/>
		<updated>2009-10-09T22:28:19Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* AspectR */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC. For a better definition, go to [[http://en.wikipedia.org/wiki/AspectJ Appendix 1]]&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ. For a clearer definition, go to [[http://eclipse.org/ajdt/ Appendix 2]].&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
== AspectR == &lt;br /&gt;
&lt;br /&gt;
Aspect-oriented programming concepts to Ruby is provided by AspectR. Essentially it allows you to wrap code around existing methods in your classes. This can be a good thing (and even affect how you design your code) since it separates different concerns into different parts of the code. It is somewhat similar to AspectJ. [[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Main features of AspectR: &lt;br /&gt;
&lt;br /&gt;
•       Join points&lt;br /&gt;
&lt;br /&gt;
•	Object receives method/constructor call &lt;br /&gt;
&lt;br /&gt;
•	Field accessed (if access is via getter/setter method)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advices: before (pre), after returning and after throwing (post)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advices can access:&lt;br /&gt;
&lt;br /&gt;
•	Object and method receiving call&lt;br /&gt;
&lt;br /&gt;
•	Arguments to call&lt;br /&gt;
&lt;br /&gt;
•	Return value&lt;br /&gt;
&lt;br /&gt;
•	exceptions raised&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aspects: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
•	Supports &amp;quot;abstract&amp;quot; Aspects and overriding between advices.&lt;br /&gt;
&lt;br /&gt;
•	Wildcards (really regexps) can be used in pointcut designators, ie. to specify classes and methods to wrap advices to&lt;br /&gt;
&lt;br /&gt;
•	Pointcut parameters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AspectR lets a module wrap any number of methods in other classes (or objects) with the &amp;quot;advice&amp;quot; methods (in the lingo of Aspect/J) of the module.&lt;br /&gt;
&lt;br /&gt;
        source: http://aspectr.sourceforge.net/&lt;br /&gt;
        require 'aspectr'&lt;br /&gt;
        include AspectR&lt;br /&gt;
        class MyAspect &amp;lt; Aspect&lt;br /&gt;
        def someAdviceMethod(method, object, exitstatus, *args)&lt;br /&gt;
             ...&lt;br /&gt;
        end&lt;br /&gt;
        ... some other advice methods ...&lt;br /&gt;
        end&lt;br /&gt;
        ma = MyAspect.new&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, ... methods to wrap...) or&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, /patternToWrap/) or&lt;br /&gt;
        AspectR.wrap_classes(ma, :preAdvice, :postAdvice,&lt;br /&gt;
       [Class1, Class2], ...methods to wrap...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advice methods are passed a variable number of parameters: the first is the name of the method currently being wrapped the second is the object receiving the method call the third is the exit/return status:&lt;br /&gt;
&lt;br /&gt;
        source:http://aspectr.sourceforge.net/&lt;br /&gt;
        Array with return value(s) if the method exited normally&lt;br /&gt;
        true if the method exited with an exception&lt;br /&gt;
        nil if the method hasn't yet exited (for preAdvice)&lt;br /&gt;
the rest are the arguments that were passed to the wrapped method.[[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquarium is a framework that implements Aspect-Oriented Programming (AOP) for Ruby.&lt;br /&gt;
Aquarium provides a Domain Specific Language (DSL) with which you can express “aspectual” system behaviour in a modular way, i.e.,using a succinct language and without repeating yourself all over your code base.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
Imagine you want to trace all invocations of the public, instance methods in all classes whose names end with “Service”. Here’s how you can implement that behavior in Aquarium:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL before :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args log &amp;quot;Entering:    &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 after :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|log &amp;quot;Leaving:              &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The #before advice adds behavior that is invoked before each method is invoked, in this case, it logs a message with the name of the executing class and method, followed by the list of arguments passed to the method.&lt;br /&gt;
The #after advice adds similar behavior the is invoked after each method is invoked.&lt;br /&gt;
&lt;br /&gt;
A more succinct implementation of this behavior uses #around advice:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL around :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args| log &amp;quot;Entering: &lt;br /&gt;
 {join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result = join_point.proceed&lt;br /&gt;
 log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result  # block needs to return the result of the &amp;quot;proceed&amp;quot;!&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The special method #proceed invokes the advised method, passing it the args list (by default). For #around advice, you must call#proceed unless you specifically don’t want the original method called.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
'''1'''. AspectJ is an aspect-oriented extension created at PARC for the Java programming language. It is available in Eclipse Foundation   open-source projects, both stand-alone and integrated into Eclipse. For more information refer to: http://en.wikipedia.org/wiki/AspectJ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''2'''. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
== References &amp;amp; Resources ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;br /&gt;
&lt;br /&gt;
[4]http://rubyforge.org/projects/aquarium/&lt;br /&gt;
&lt;br /&gt;
[5]http://aspectr.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
[6]http://aquarium.rubyforge.org/examples.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24624</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24624"/>
		<updated>2009-10-09T22:27:05Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* AspectR */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC. For a better definition, go to [[http://en.wikipedia.org/wiki/AspectJ Appendix 1]]&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ. For a clearer definition, go to [[http://eclipse.org/ajdt/ Appendix 2]].&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
== AspectR == &lt;br /&gt;
&lt;br /&gt;
Aspect-oriented programming concepts to Ruby is provided by AspectR. Essentially it allows you to wrap code around existing methods in your classes. This can be a good thing (and even affect how you design your code) since it separates different concerns into different parts of the code. It is somewhat similar to AspectJ. [[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Main features of AspectR: &lt;br /&gt;
&lt;br /&gt;
Join points:&lt;br /&gt;
&lt;br /&gt;
•	Object receives method/constructor call &lt;br /&gt;
&lt;br /&gt;
•	Field accessed (if access is via getter/setter meth) &lt;br /&gt;
&lt;br /&gt;
Advices: before (pre), after returning and after throwing (post)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advices can access:&lt;br /&gt;
&lt;br /&gt;
•	Object and method receiving call&lt;br /&gt;
&lt;br /&gt;
•	Arguments to call&lt;br /&gt;
&lt;br /&gt;
•	Return value&lt;br /&gt;
&lt;br /&gt;
•	exceptions raised&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aspects: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
•	Supports &amp;quot;abstract&amp;quot; Aspects and overriding between advices.&lt;br /&gt;
&lt;br /&gt;
•	Wildcards (really regexps) can be used in pointcut designators, ie. to specify classes and methods to wrap advices to&lt;br /&gt;
&lt;br /&gt;
•	Pointcut parameters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AspectR lets a module wrap any number of methods in other classes (or objects) with the &amp;quot;advice&amp;quot; methods (in the lingo of Aspect/J) of the module.&lt;br /&gt;
&lt;br /&gt;
        source: http://aspectr.sourceforge.net/&lt;br /&gt;
        require 'aspectr'&lt;br /&gt;
        include AspectR&lt;br /&gt;
        class MyAspect &amp;lt; Aspect&lt;br /&gt;
        def someAdviceMethod(method, object, exitstatus, *args)&lt;br /&gt;
             ...&lt;br /&gt;
        end&lt;br /&gt;
        ... some other advice methods ...&lt;br /&gt;
        end&lt;br /&gt;
        ma = MyAspect.new&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, ... methods to wrap...) or&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, /patternToWrap/) or&lt;br /&gt;
        AspectR.wrap_classes(ma, :preAdvice, :postAdvice,&lt;br /&gt;
       [Class1, Class2], ...methods to wrap...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advice methods are passed a variable number of parameters: the first is the name of the method currently being wrapped the second is the object receiving the method call the third is the exit/return status:&lt;br /&gt;
&lt;br /&gt;
        source:http://aspectr.sourceforge.net/&lt;br /&gt;
        Array with return value(s) if the method exited normally&lt;br /&gt;
        true if the method exited with an exception&lt;br /&gt;
        nil if the method hasn't yet exited (for preAdvice)&lt;br /&gt;
the rest are the arguments that were passed to the wrapped method.[[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquarium is a framework that implements Aspect-Oriented Programming (AOP) for Ruby.&lt;br /&gt;
Aquarium provides a Domain Specific Language (DSL) with which you can express “aspectual” system behaviour in a modular way, i.e.,using a succinct language and without repeating yourself all over your code base.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
Imagine you want to trace all invocations of the public, instance methods in all classes whose names end with “Service”. Here’s how you can implement that behavior in Aquarium:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL before :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args log &amp;quot;Entering:    &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 after :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|log &amp;quot;Leaving:              &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The #before advice adds behavior that is invoked before each method is invoked, in this case, it logs a message with the name of the executing class and method, followed by the list of arguments passed to the method.&lt;br /&gt;
The #after advice adds similar behavior the is invoked after each method is invoked.&lt;br /&gt;
&lt;br /&gt;
A more succinct implementation of this behavior uses #around advice:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL around :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args| log &amp;quot;Entering: &lt;br /&gt;
 {join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result = join_point.proceed&lt;br /&gt;
 log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result  # block needs to return the result of the &amp;quot;proceed&amp;quot;!&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The special method #proceed invokes the advised method, passing it the args list (by default). For #around advice, you must call#proceed unless you specifically don’t want the original method called.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
'''1'''. AspectJ is an aspect-oriented extension created at PARC for the Java programming language. It is available in Eclipse Foundation   open-source projects, both stand-alone and integrated into Eclipse. For more information refer to: http://en.wikipedia.org/wiki/AspectJ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''2'''. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
== References &amp;amp; Resources ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;br /&gt;
&lt;br /&gt;
[4]http://rubyforge.org/projects/aquarium/&lt;br /&gt;
&lt;br /&gt;
[5]http://aspectr.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
[6]http://aquarium.rubyforge.org/examples.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24593</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24593"/>
		<updated>2009-10-09T22:16:39Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* AspectJ Plugin tool */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC. For a better definition, go to [[http://en.wikipedia.org/wiki/AspectJ Appendix 1]]&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ. For a clearer definition, go to [[http://eclipse.org/ajdt/ Appendix 2]].&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
== AspectR == &lt;br /&gt;
&lt;br /&gt;
Aspect-oriented programming concepts to Ruby is provided by AspectR. Essentially it allows you to wrap code around existing methods in your classes. This can be a good thing (and even affect how you design your code) since it separates different concerns into different parts of the code. It is somewhat similar to AspectJ. [[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Main features of AspectR (in AspectJ lingo): &lt;br /&gt;
&lt;br /&gt;
Join points:&lt;br /&gt;
&lt;br /&gt;
•	Object receives method/constructor call &lt;br /&gt;
&lt;br /&gt;
•	Field accessed (if access is via getter/setter meth) &lt;br /&gt;
&lt;br /&gt;
Advices: before (pre), after returning and after throwing (post)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advices can access:&lt;br /&gt;
&lt;br /&gt;
•	Object and method receiving call&lt;br /&gt;
&lt;br /&gt;
•	Arguments to call&lt;br /&gt;
&lt;br /&gt;
•	Return value&lt;br /&gt;
&lt;br /&gt;
•	exceptions raised&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aspects: classes inheriting Aspect&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
•	Supports &amp;quot;abstract&amp;quot; Aspects and overriding between advices.&lt;br /&gt;
&lt;br /&gt;
•	Wildcards (really regexps) can be used in pointcut designators, ie. to specify classes and methods to wrap advices to&lt;br /&gt;
&lt;br /&gt;
•	Pointcut parameters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AspectR lets a module wrap any number of methods in other classes (or objects) with the &amp;quot;advice&amp;quot; methods (in the lingo of Aspect/J) of the module.&lt;br /&gt;
&lt;br /&gt;
        source: http://aspectr.sourceforge.net/&lt;br /&gt;
        require 'aspectr'&lt;br /&gt;
        include AspectR&lt;br /&gt;
        class MyAspect &amp;lt; Aspect&lt;br /&gt;
        def someAdviceMethod(method, object, exitstatus, *args)&lt;br /&gt;
             ...&lt;br /&gt;
        end&lt;br /&gt;
        ... some other advice methods ...&lt;br /&gt;
        end&lt;br /&gt;
        ma = MyAspect.new&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, ... methods to wrap...) or&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, /patternToWrap/) or&lt;br /&gt;
        AspectR.wrap_classes(ma, :preAdvice, :postAdvice,&lt;br /&gt;
       [Class1, Class2], ...methods to wrap...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advice methods are passed a variable number of parameters: the first is the name of the method currently being wrapped the second is the object receiving the method call the third is the exit/return status:&lt;br /&gt;
&lt;br /&gt;
        source:http://aspectr.sourceforge.net/&lt;br /&gt;
        Array with return value(s) if the method exited normally&lt;br /&gt;
        true if the method exited with an exception&lt;br /&gt;
        nil if the method hasn't yet exited (for preAdvice)&lt;br /&gt;
the rest are the arguments that were passed to the wrapped method.[[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquarium is a framework that implements Aspect-Oriented Programming (AOP) for Ruby.&lt;br /&gt;
Aquarium provides a Domain Specific Language (DSL) with which you can express “aspectual” system behaviour in a modular way, i.e.,using a succinct language and without repeating yourself all over your code base.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
Imagine you want to trace all invocations of the public, instance methods in all classes whose names end with “Service”. Here’s how you can implement that behavior in Aquarium:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL before :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args log &amp;quot;Entering:    &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 after :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|log &amp;quot;Leaving:              &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The #before advice adds behavior that is invoked before each method is invoked, in this case, it logs a message with the name of the executing class and method, followed by the list of arguments passed to the method.&lt;br /&gt;
The #after advice adds similar behavior the is invoked after each method is invoked.&lt;br /&gt;
&lt;br /&gt;
A more succinct implementation of this behavior uses #around advice:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL around :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args| log &amp;quot;Entering: &lt;br /&gt;
 {join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result = join_point.proceed&lt;br /&gt;
 log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result  # block needs to return the result of the &amp;quot;proceed&amp;quot;!&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The special method #proceed invokes the advised method, passing it the args list (by default). For #around advice, you must call#proceed unless you specifically don’t want the original method called.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
'''1'''. AspectJ is an aspect-oriented extension created at PARC for the Java programming language. It is available in Eclipse Foundation   open-source projects, both stand-alone and integrated into Eclipse. For more information refer to: http://en.wikipedia.org/wiki/AspectJ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''2'''. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
== References &amp;amp; Resources ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;br /&gt;
&lt;br /&gt;
[4]http://rubyforge.org/projects/aquarium/&lt;br /&gt;
&lt;br /&gt;
[5]http://aspectr.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
[6]http://aquarium.rubyforge.org/examples.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24591</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24591"/>
		<updated>2009-10-09T22:16:19Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* AspectJ Plugin tool */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC. For a better definition, go to [[http://en.wikipedia.org/wiki/AspectJ Appendix 1]]&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ. For a clearer definition, go to [[http://eclipse.org/ajdt/ Appendix 2]]&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
== AspectR == &lt;br /&gt;
&lt;br /&gt;
Aspect-oriented programming concepts to Ruby is provided by AspectR. Essentially it allows you to wrap code around existing methods in your classes. This can be a good thing (and even affect how you design your code) since it separates different concerns into different parts of the code. It is somewhat similar to AspectJ. [[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Main features of AspectR (in AspectJ lingo): &lt;br /&gt;
&lt;br /&gt;
Join points:&lt;br /&gt;
&lt;br /&gt;
•	Object receives method/constructor call &lt;br /&gt;
&lt;br /&gt;
•	Field accessed (if access is via getter/setter meth) &lt;br /&gt;
&lt;br /&gt;
Advices: before (pre), after returning and after throwing (post)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advices can access:&lt;br /&gt;
&lt;br /&gt;
•	Object and method receiving call&lt;br /&gt;
&lt;br /&gt;
•	Arguments to call&lt;br /&gt;
&lt;br /&gt;
•	Return value&lt;br /&gt;
&lt;br /&gt;
•	exceptions raised&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aspects: classes inheriting Aspect&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
•	Supports &amp;quot;abstract&amp;quot; Aspects and overriding between advices.&lt;br /&gt;
&lt;br /&gt;
•	Wildcards (really regexps) can be used in pointcut designators, ie. to specify classes and methods to wrap advices to&lt;br /&gt;
&lt;br /&gt;
•	Pointcut parameters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AspectR lets a module wrap any number of methods in other classes (or objects) with the &amp;quot;advice&amp;quot; methods (in the lingo of Aspect/J) of the module.&lt;br /&gt;
&lt;br /&gt;
        source: http://aspectr.sourceforge.net/&lt;br /&gt;
        require 'aspectr'&lt;br /&gt;
        include AspectR&lt;br /&gt;
        class MyAspect &amp;lt; Aspect&lt;br /&gt;
        def someAdviceMethod(method, object, exitstatus, *args)&lt;br /&gt;
             ...&lt;br /&gt;
        end&lt;br /&gt;
        ... some other advice methods ...&lt;br /&gt;
        end&lt;br /&gt;
        ma = MyAspect.new&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, ... methods to wrap...) or&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, /patternToWrap/) or&lt;br /&gt;
        AspectR.wrap_classes(ma, :preAdvice, :postAdvice,&lt;br /&gt;
       [Class1, Class2], ...methods to wrap...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advice methods are passed a variable number of parameters: the first is the name of the method currently being wrapped the second is the object receiving the method call the third is the exit/return status:&lt;br /&gt;
&lt;br /&gt;
        source:http://aspectr.sourceforge.net/&lt;br /&gt;
        Array with return value(s) if the method exited normally&lt;br /&gt;
        true if the method exited with an exception&lt;br /&gt;
        nil if the method hasn't yet exited (for preAdvice)&lt;br /&gt;
the rest are the arguments that were passed to the wrapped method.[[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquarium is a framework that implements Aspect-Oriented Programming (AOP) for Ruby.&lt;br /&gt;
Aquarium provides a Domain Specific Language (DSL) with which you can express “aspectual” system behaviour in a modular way, i.e.,using a succinct language and without repeating yourself all over your code base.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
Imagine you want to trace all invocations of the public, instance methods in all classes whose names end with “Service”. Here’s how you can implement that behavior in Aquarium:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL before :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args log &amp;quot;Entering:    &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 after :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|log &amp;quot;Leaving:              &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The #before advice adds behavior that is invoked before each method is invoked, in this case, it logs a message with the name of the executing class and method, followed by the list of arguments passed to the method.&lt;br /&gt;
The #after advice adds similar behavior the is invoked after each method is invoked.&lt;br /&gt;
&lt;br /&gt;
A more succinct implementation of this behavior uses #around advice:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL around :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args| log &amp;quot;Entering: &lt;br /&gt;
 {join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result = join_point.proceed&lt;br /&gt;
 log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result  # block needs to return the result of the &amp;quot;proceed&amp;quot;!&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The special method #proceed invokes the advised method, passing it the args list (by default). For #around advice, you must call#proceed unless you specifically don’t want the original method called.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
'''1'''. AspectJ is an aspect-oriented extension created at PARC for the Java programming language. It is available in Eclipse Foundation   open-source projects, both stand-alone and integrated into Eclipse. For more information refer to: http://en.wikipedia.org/wiki/AspectJ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''2'''. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
== References &amp;amp; Resources ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;br /&gt;
&lt;br /&gt;
[4]http://rubyforge.org/projects/aquarium/&lt;br /&gt;
&lt;br /&gt;
[5]http://aspectr.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
[6]http://aquarium.rubyforge.org/examples.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24588</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24588"/>
		<updated>2009-10-09T22:15:48Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* AspectJ Plugin tool */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC. For a better definition, go to [[http://en.wikipedia.org/wiki/AspectJ Appendix 1]]&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ. For a clearer definition, go to [[ Appendix 2]]&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
== AspectR == &lt;br /&gt;
&lt;br /&gt;
Aspect-oriented programming concepts to Ruby is provided by AspectR. Essentially it allows you to wrap code around existing methods in your classes. This can be a good thing (and even affect how you design your code) since it separates different concerns into different parts of the code. It is somewhat similar to AspectJ. [[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Main features of AspectR (in AspectJ lingo): &lt;br /&gt;
&lt;br /&gt;
Join points:&lt;br /&gt;
&lt;br /&gt;
•	Object receives method/constructor call &lt;br /&gt;
&lt;br /&gt;
•	Field accessed (if access is via getter/setter meth) &lt;br /&gt;
&lt;br /&gt;
Advices: before (pre), after returning and after throwing (post)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advices can access:&lt;br /&gt;
&lt;br /&gt;
•	Object and method receiving call&lt;br /&gt;
&lt;br /&gt;
•	Arguments to call&lt;br /&gt;
&lt;br /&gt;
•	Return value&lt;br /&gt;
&lt;br /&gt;
•	exceptions raised&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aspects: classes inheriting Aspect&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
•	Supports &amp;quot;abstract&amp;quot; Aspects and overriding between advices.&lt;br /&gt;
&lt;br /&gt;
•	Wildcards (really regexps) can be used in pointcut designators, ie. to specify classes and methods to wrap advices to&lt;br /&gt;
&lt;br /&gt;
•	Pointcut parameters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AspectR lets a module wrap any number of methods in other classes (or objects) with the &amp;quot;advice&amp;quot; methods (in the lingo of Aspect/J) of the module.&lt;br /&gt;
&lt;br /&gt;
        source: http://aspectr.sourceforge.net/&lt;br /&gt;
        require 'aspectr'&lt;br /&gt;
        include AspectR&lt;br /&gt;
        class MyAspect &amp;lt; Aspect&lt;br /&gt;
        def someAdviceMethod(method, object, exitstatus, *args)&lt;br /&gt;
             ...&lt;br /&gt;
        end&lt;br /&gt;
        ... some other advice methods ...&lt;br /&gt;
        end&lt;br /&gt;
        ma = MyAspect.new&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, ... methods to wrap...) or&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, /patternToWrap/) or&lt;br /&gt;
        AspectR.wrap_classes(ma, :preAdvice, :postAdvice,&lt;br /&gt;
       [Class1, Class2], ...methods to wrap...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advice methods are passed a variable number of parameters: the first is the name of the method currently being wrapped the second is the object receiving the method call the third is the exit/return status:&lt;br /&gt;
&lt;br /&gt;
        source:http://aspectr.sourceforge.net/&lt;br /&gt;
        Array with return value(s) if the method exited normally&lt;br /&gt;
        true if the method exited with an exception&lt;br /&gt;
        nil if the method hasn't yet exited (for preAdvice)&lt;br /&gt;
the rest are the arguments that were passed to the wrapped method.[[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquarium is a framework that implements Aspect-Oriented Programming (AOP) for Ruby.&lt;br /&gt;
Aquarium provides a Domain Specific Language (DSL) with which you can express “aspectual” system behaviour in a modular way, i.e.,using a succinct language and without repeating yourself all over your code base.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
Imagine you want to trace all invocations of the public, instance methods in all classes whose names end with “Service”. Here’s how you can implement that behavior in Aquarium:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL before :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args log &amp;quot;Entering:    &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 after :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|log &amp;quot;Leaving:              &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The #before advice adds behavior that is invoked before each method is invoked, in this case, it logs a message with the name of the executing class and method, followed by the list of arguments passed to the method.&lt;br /&gt;
The #after advice adds similar behavior the is invoked after each method is invoked.&lt;br /&gt;
&lt;br /&gt;
A more succinct implementation of this behavior uses #around advice:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL around :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args| log &amp;quot;Entering: &lt;br /&gt;
 {join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result = join_point.proceed&lt;br /&gt;
 log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result  # block needs to return the result of the &amp;quot;proceed&amp;quot;!&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The special method #proceed invokes the advised method, passing it the args list (by default). For #around advice, you must call#proceed unless you specifically don’t want the original method called.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
'''1'''. AspectJ is an aspect-oriented extension created at PARC for the Java programming language. It is available in Eclipse Foundation   open-source projects, both stand-alone and integrated into Eclipse. For more information refer to: http://en.wikipedia.org/wiki/AspectJ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''2'''. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
== References &amp;amp; Resources ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;br /&gt;
&lt;br /&gt;
[4]http://rubyforge.org/projects/aquarium/&lt;br /&gt;
&lt;br /&gt;
[5]http://aspectr.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
[6]http://aquarium.rubyforge.org/examples.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24583</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24583"/>
		<updated>2009-10-09T22:14:53Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* AspectJ */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC. For a better definition, go to [[http://en.wikipedia.org/wiki/AspectJ Appendix 1]]&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== AspectR == &lt;br /&gt;
&lt;br /&gt;
Aspect-oriented programming concepts to Ruby is provided by AspectR. Essentially it allows you to wrap code around existing methods in your classes. This can be a good thing (and even affect how you design your code) since it separates different concerns into different parts of the code. It is somewhat similar to AspectJ. [[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Main features of AspectR (in AspectJ lingo): &lt;br /&gt;
&lt;br /&gt;
Join points:&lt;br /&gt;
&lt;br /&gt;
•	Object receives method/constructor call &lt;br /&gt;
&lt;br /&gt;
•	Field accessed (if access is via getter/setter meth) &lt;br /&gt;
&lt;br /&gt;
Advices: before (pre), after returning and after throwing (post)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advices can access:&lt;br /&gt;
&lt;br /&gt;
•	Object and method receiving call&lt;br /&gt;
&lt;br /&gt;
•	Arguments to call&lt;br /&gt;
&lt;br /&gt;
•	Return value&lt;br /&gt;
&lt;br /&gt;
•	exceptions raised&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aspects: classes inheriting Aspect&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
•	Supports &amp;quot;abstract&amp;quot; Aspects and overriding between advices.&lt;br /&gt;
&lt;br /&gt;
•	Wildcards (really regexps) can be used in pointcut designators, ie. to specify classes and methods to wrap advices to&lt;br /&gt;
&lt;br /&gt;
•	Pointcut parameters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AspectR lets a module wrap any number of methods in other classes (or objects) with the &amp;quot;advice&amp;quot; methods (in the lingo of Aspect/J) of the module.&lt;br /&gt;
&lt;br /&gt;
        source: http://aspectr.sourceforge.net/&lt;br /&gt;
        require 'aspectr'&lt;br /&gt;
        include AspectR&lt;br /&gt;
        class MyAspect &amp;lt; Aspect&lt;br /&gt;
        def someAdviceMethod(method, object, exitstatus, *args)&lt;br /&gt;
             ...&lt;br /&gt;
        end&lt;br /&gt;
        ... some other advice methods ...&lt;br /&gt;
        end&lt;br /&gt;
        ma = MyAspect.new&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, ... methods to wrap...) or&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, /patternToWrap/) or&lt;br /&gt;
        AspectR.wrap_classes(ma, :preAdvice, :postAdvice,&lt;br /&gt;
       [Class1, Class2], ...methods to wrap...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advice methods are passed a variable number of parameters: the first is the name of the method currently being wrapped the second is the object receiving the method call the third is the exit/return status:&lt;br /&gt;
&lt;br /&gt;
        source:http://aspectr.sourceforge.net/&lt;br /&gt;
        Array with return value(s) if the method exited normally&lt;br /&gt;
        true if the method exited with an exception&lt;br /&gt;
        nil if the method hasn't yet exited (for preAdvice)&lt;br /&gt;
the rest are the arguments that were passed to the wrapped method.[[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquarium is a framework that implements Aspect-Oriented Programming (AOP) for Ruby.&lt;br /&gt;
Aquarium provides a Domain Specific Language (DSL) with which you can express “aspectual” system behaviour in a modular way, i.e.,using a succinct language and without repeating yourself all over your code base.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
Imagine you want to trace all invocations of the public, instance methods in all classes whose names end with “Service”. Here’s how you can implement that behavior in Aquarium:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL before :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args log &amp;quot;Entering:    &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 after :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|log &amp;quot;Leaving:              &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The #before advice adds behavior that is invoked before each method is invoked, in this case, it logs a message with the name of the executing class and method, followed by the list of arguments passed to the method.&lt;br /&gt;
The #after advice adds similar behavior the is invoked after each method is invoked.&lt;br /&gt;
&lt;br /&gt;
A more succinct implementation of this behavior uses #around advice:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL around :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args| log &amp;quot;Entering: &lt;br /&gt;
 {join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result = join_point.proceed&lt;br /&gt;
 log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result  # block needs to return the result of the &amp;quot;proceed&amp;quot;!&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The special method #proceed invokes the advised method, passing it the args list (by default). For #around advice, you must call#proceed unless you specifically don’t want the original method called.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
'''1'''. AspectJ is an aspect-oriented extension created at PARC for the Java programming language. It is available in Eclipse Foundation   open-source projects, both stand-alone and integrated into Eclipse. For more information refer to: http://en.wikipedia.org/wiki/AspectJ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''2'''. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
== References &amp;amp; Resources ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;br /&gt;
&lt;br /&gt;
[4]http://rubyforge.org/projects/aquarium/&lt;br /&gt;
&lt;br /&gt;
[5]http://aspectr.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
[6]http://aquarium.rubyforge.org/examples.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24580</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24580"/>
		<updated>2009-10-09T22:13:56Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* Appendix */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC.&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== AspectR == &lt;br /&gt;
&lt;br /&gt;
Aspect-oriented programming concepts to Ruby is provided by AspectR. Essentially it allows you to wrap code around existing methods in your classes. This can be a good thing (and even affect how you design your code) since it separates different concerns into different parts of the code. It is somewhat similar to AspectJ. [[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Main features of AspectR (in AspectJ lingo): &lt;br /&gt;
&lt;br /&gt;
Join points:&lt;br /&gt;
&lt;br /&gt;
•	Object receives method/constructor call &lt;br /&gt;
&lt;br /&gt;
•	Field accessed (if access is via getter/setter meth) &lt;br /&gt;
&lt;br /&gt;
Advices: before (pre), after returning and after throwing (post)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advices can access:&lt;br /&gt;
&lt;br /&gt;
•	Object and method receiving call&lt;br /&gt;
&lt;br /&gt;
•	Arguments to call&lt;br /&gt;
&lt;br /&gt;
•	Return value&lt;br /&gt;
&lt;br /&gt;
•	exceptions raised&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aspects: classes inheriting Aspect&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
•	Supports &amp;quot;abstract&amp;quot; Aspects and overriding between advices.&lt;br /&gt;
&lt;br /&gt;
•	Wildcards (really regexps) can be used in pointcut designators, ie. to specify classes and methods to wrap advices to&lt;br /&gt;
&lt;br /&gt;
•	Pointcut parameters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AspectR lets a module wrap any number of methods in other classes (or objects) with the &amp;quot;advice&amp;quot; methods (in the lingo of Aspect/J) of the module.&lt;br /&gt;
&lt;br /&gt;
        source: http://aspectr.sourceforge.net/&lt;br /&gt;
        require 'aspectr'&lt;br /&gt;
        include AspectR&lt;br /&gt;
        class MyAspect &amp;lt; Aspect&lt;br /&gt;
        def someAdviceMethod(method, object, exitstatus, *args)&lt;br /&gt;
             ...&lt;br /&gt;
        end&lt;br /&gt;
        ... some other advice methods ...&lt;br /&gt;
        end&lt;br /&gt;
        ma = MyAspect.new&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, ... methods to wrap...) or&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, /patternToWrap/) or&lt;br /&gt;
        AspectR.wrap_classes(ma, :preAdvice, :postAdvice,&lt;br /&gt;
       [Class1, Class2], ...methods to wrap...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advice methods are passed a variable number of parameters: the first is the name of the method currently being wrapped the second is the object receiving the method call the third is the exit/return status:&lt;br /&gt;
&lt;br /&gt;
        source:http://aspectr.sourceforge.net/&lt;br /&gt;
        Array with return value(s) if the method exited normally&lt;br /&gt;
        true if the method exited with an exception&lt;br /&gt;
        nil if the method hasn't yet exited (for preAdvice)&lt;br /&gt;
the rest are the arguments that were passed to the wrapped method.[[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquarium is a framework that implements Aspect-Oriented Programming (AOP) for Ruby.&lt;br /&gt;
Aquarium provides a Domain Specific Language (DSL) with which you can express “aspectual” system behaviour in a modular way, i.e.,using a succinct language and without repeating yourself all over your code base.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
Imagine you want to trace all invocations of the public, instance methods in all classes whose names end with “Service”. Here’s how you can implement that behavior in Aquarium:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL before :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args log &amp;quot;Entering:    &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 after :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|log &amp;quot;Leaving:              &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The #before advice adds behavior that is invoked before each method is invoked, in this case, it logs a message with the name of the executing class and method, followed by the list of arguments passed to the method.&lt;br /&gt;
The #after advice adds similar behavior the is invoked after each method is invoked.&lt;br /&gt;
&lt;br /&gt;
A more succinct implementation of this behavior uses #around advice:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL around :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args| log &amp;quot;Entering: &lt;br /&gt;
 {join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result = join_point.proceed&lt;br /&gt;
 log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result  # block needs to return the result of the &amp;quot;proceed&amp;quot;!&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The special method #proceed invokes the advised method, passing it the args list (by default). For #around advice, you must call#proceed unless you specifically don’t want the original method called.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
'''1'''. AspectJ is an aspect-oriented extension created at PARC for the Java programming language. It is available in Eclipse Foundation   open-source projects, both stand-alone and integrated into Eclipse. For more information refer to: http://en.wikipedia.org/wiki/AspectJ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''2'''. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
== References &amp;amp; Resources ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;br /&gt;
&lt;br /&gt;
[4]http://rubyforge.org/projects/aquarium/&lt;br /&gt;
&lt;br /&gt;
[5]http://aspectr.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
[6]http://aquarium.rubyforge.org/examples.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24567</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24567"/>
		<updated>2009-10-09T22:07:04Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* AspectR */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC.&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== AspectR == &lt;br /&gt;
&lt;br /&gt;
Aspect-oriented programming concepts to Ruby is provided by AspectR. Essentially it allows you to wrap code around existing methods in your classes. This can be a good thing (and even affect how you design your code) since it separates different concerns into different parts of the code. It is somewhat similar to AspectJ. [[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Main features of AspectR (in AspectJ lingo): &lt;br /&gt;
&lt;br /&gt;
Join points:&lt;br /&gt;
&lt;br /&gt;
•	Object receives method/constructor call &lt;br /&gt;
&lt;br /&gt;
•	Field accessed (if access is via getter/setter meth) &lt;br /&gt;
&lt;br /&gt;
Advices: before (pre), after returning and after throwing (post)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advices can access:&lt;br /&gt;
&lt;br /&gt;
•	Object and method receiving call&lt;br /&gt;
&lt;br /&gt;
•	Arguments to call&lt;br /&gt;
&lt;br /&gt;
•	Return value&lt;br /&gt;
&lt;br /&gt;
•	exceptions raised&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aspects: classes inheriting Aspect&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
•	Supports &amp;quot;abstract&amp;quot; Aspects and overriding between advices.&lt;br /&gt;
&lt;br /&gt;
•	Wildcards (really regexps) can be used in pointcut designators, ie. to specify classes and methods to wrap advices to&lt;br /&gt;
&lt;br /&gt;
•	Pointcut parameters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AspectR lets a module wrap any number of methods in other classes (or objects) with the &amp;quot;advice&amp;quot; methods (in the lingo of Aspect/J) of the module.&lt;br /&gt;
&lt;br /&gt;
        source: http://aspectr.sourceforge.net/&lt;br /&gt;
        require 'aspectr'&lt;br /&gt;
        include AspectR&lt;br /&gt;
        class MyAspect &amp;lt; Aspect&lt;br /&gt;
        def someAdviceMethod(method, object, exitstatus, *args)&lt;br /&gt;
             ...&lt;br /&gt;
        end&lt;br /&gt;
        ... some other advice methods ...&lt;br /&gt;
        end&lt;br /&gt;
        ma = MyAspect.new&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, ... methods to wrap...) or&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, /patternToWrap/) or&lt;br /&gt;
        AspectR.wrap_classes(ma, :preAdvice, :postAdvice,&lt;br /&gt;
       [Class1, Class2], ...methods to wrap...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advice methods are passed a variable number of parameters: the first is the name of the method currently being wrapped the second is the object receiving the method call the third is the exit/return status:&lt;br /&gt;
&lt;br /&gt;
        source:http://aspectr.sourceforge.net/&lt;br /&gt;
        Array with return value(s) if the method exited normally&lt;br /&gt;
        true if the method exited with an exception&lt;br /&gt;
        nil if the method hasn't yet exited (for preAdvice)&lt;br /&gt;
the rest are the arguments that were passed to the wrapped method.[[http://aspectr.sourceforge.net/ 5]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquarium is a framework that implements Aspect-Oriented Programming (AOP) for Ruby.&lt;br /&gt;
Aquarium provides a Domain Specific Language (DSL) with which you can express “aspectual” system behaviour in a modular way, i.e.,using a succinct language and without repeating yourself all over your code base.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
Imagine you want to trace all invocations of the public, instance methods in all classes whose names end with “Service”. Here’s how you can implement that behavior in Aquarium:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL before :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args log &amp;quot;Entering:    &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 after :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|log &amp;quot;Leaving:              &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The #before advice adds behavior that is invoked before each method is invoked, in this case, it logs a message with the name of the executing class and method, followed by the list of arguments passed to the method.&lt;br /&gt;
The #after advice adds similar behavior the is invoked after each method is invoked.&lt;br /&gt;
&lt;br /&gt;
A more succinct implementation of this behavior uses #around advice:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL around :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args| log &amp;quot;Entering: &lt;br /&gt;
 {join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result = join_point.proceed&lt;br /&gt;
 log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result  # block needs to return the result of the &amp;quot;proceed&amp;quot;!&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The special method #proceed invokes the advised method, passing it the args list (by default). For #around advice, you must call#proceed unless you specifically don’t want the original method called.[[http://aquarium.rubyforge.org/index.html 6]]&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
1. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References &amp;amp; Resources ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;br /&gt;
&lt;br /&gt;
[4]http://rubyforge.org/projects/aquarium/&lt;br /&gt;
&lt;br /&gt;
[5]http://aspectr.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
[6]http://aquarium.rubyforge.org/examples.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24554</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24554"/>
		<updated>2009-10-09T22:01:22Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* AspectR */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC.&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== AspectR == &lt;br /&gt;
&lt;br /&gt;
Aspect-oriented programming concepts to Ruby is provided by AspectR. Essentially it allows you to wrap code around existing methods in your classes. This can be a good thing (and even affect how you design your code) since it separates different concerns into different parts of the code. It is somewhat similar to AspectJ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Main features of AspectR (in AspectJ lingo): &lt;br /&gt;
&lt;br /&gt;
Join points:&lt;br /&gt;
&lt;br /&gt;
•	Object receives method/constructor call &lt;br /&gt;
&lt;br /&gt;
•	Field accessed (if access is via getter/setter meth) &lt;br /&gt;
&lt;br /&gt;
Advices: before (pre), after returning and after throwing (post)&lt;br /&gt;
&lt;br /&gt;
Advices can access:&lt;br /&gt;
&lt;br /&gt;
•	Object and method receiving call&lt;br /&gt;
&lt;br /&gt;
•	Arguments to call&lt;br /&gt;
&lt;br /&gt;
•	Return value&lt;br /&gt;
&lt;br /&gt;
•	exceptions raised&lt;br /&gt;
&lt;br /&gt;
Aspects: classes inheriting Aspect.&lt;br /&gt;
&lt;br /&gt;
Supports &amp;quot;abstract&amp;quot; Aspects and overriding between advices.&lt;br /&gt;
&lt;br /&gt;
Wildcards (really regexps) can be used in pointcut designators, ie. to specify classes and methods to wrap advices to&lt;br /&gt;
&lt;br /&gt;
Pointcut parameters. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AspectR lets a module wrap any number of methods in other classes (or objects) with the &amp;quot;advice&amp;quot; methods (in the lingo of Aspect/J) of the module.&lt;br /&gt;
&lt;br /&gt;
        source: http://aspectr.sourceforge.net/&lt;br /&gt;
        require 'aspectr'&lt;br /&gt;
        include AspectR&lt;br /&gt;
        class MyAspect &amp;lt; Aspect&lt;br /&gt;
        def someAdviceMethod(method, object, exitstatus, *args)&lt;br /&gt;
             ...&lt;br /&gt;
        end&lt;br /&gt;
        ... some other advice methods ...&lt;br /&gt;
        end&lt;br /&gt;
        ma = MyAspect.new&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, ... methods to wrap...) or&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, /patternToWrap/) or&lt;br /&gt;
        AspectR.wrap_classes(ma, :preAdvice, :postAdvice,&lt;br /&gt;
       [Class1, Class2], ...methods to wrap...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advice methods are passed a variable number of parameters: the first is the name of the method currently being wrapped the second is the object receiving the method call the third is the exit/return status:&lt;br /&gt;
        Array with return value(s) if the method exited normally&lt;br /&gt;
        true if the method exited with an exception&lt;br /&gt;
        nil if the method hasn't yet exited (for preAdvice)&lt;br /&gt;
the rest are the arguments that were passed to the wrapped method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquarium is a framework that implements Aspect-Oriented Programming (AOP) for Ruby.&lt;br /&gt;
Aquarium provides a Domain Specific Language (DSL) with which you can express “aspectual” system behaviour in a modular way, i.e.,using a succinct language and without repeating yourself all over your code base!&lt;br /&gt;
&lt;br /&gt;
Imagine you want to trace all invocations of the public, instance methods in all classes whose names end with “Service”. Here’s how you can implement that behavior in Aquarium:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL before :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args log &amp;quot;Entering:    &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 after :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|log &amp;quot;Leaving:              &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The #before advice adds behavior that is invoked before each method is invoked, in this case, it logs a message with the name of the executing class and method, followed by the list of arguments passed to the method.&lt;br /&gt;
The #after advice adds similar behavior the is invoked after each method is invoked.&lt;br /&gt;
&lt;br /&gt;
A more succinct implementation of this behavior uses #around advice:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL around :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args| log &amp;quot;Entering: &lt;br /&gt;
 {join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result = join_point.proceed&lt;br /&gt;
 log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result  # block needs to return the result of the &amp;quot;proceed&amp;quot;!&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The special method #proceed invokes the advised method, passing it the args list (by default). For #around advice, you must call#proceed unless you specifically don’t want the original method called.&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
1. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References &amp;amp; Resources ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;br /&gt;
&lt;br /&gt;
[4]http://rubyforge.org/projects/aquarium/&lt;br /&gt;
&lt;br /&gt;
[5]http://aspectr.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
[6]http://aquarium.rubyforge.org/examples.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24542</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24542"/>
		<updated>2009-10-09T21:58:24Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* AspectR */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC.&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== AspectR == &lt;br /&gt;
&lt;br /&gt;
Aspect-oriented programming concepts to Ruby is provided by AspectR. Essentially it allows you to wrap code around existing methods in your classes. This can be a good thing (and even affect how you design your code) since it separates different concerns into different parts of the code. It is somewhat similar to AspectJ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Main features of AspectR (in AspectJ lingo): &lt;br /&gt;
&lt;br /&gt;
Join points:&lt;br /&gt;
&lt;br /&gt;
•	Object receives method/constructor call &lt;br /&gt;
&lt;br /&gt;
•	Field accessed (if access is via getter/setter meth) &lt;br /&gt;
&lt;br /&gt;
Advices: before (pre), after returning and after throwing (post)&lt;br /&gt;
&lt;br /&gt;
Advices can access:&lt;br /&gt;
&lt;br /&gt;
•	Object and method receiving call&lt;br /&gt;
&lt;br /&gt;
•	Arguments to call&lt;br /&gt;
&lt;br /&gt;
•	Return value&lt;br /&gt;
&lt;br /&gt;
•	exceptions raised&lt;br /&gt;
&lt;br /&gt;
Aspects: classes inheriting Aspect.&lt;br /&gt;
&lt;br /&gt;
Supports &amp;quot;abstract&amp;quot; Aspects and overriding between advices.&lt;br /&gt;
&lt;br /&gt;
Wildcards (really regexps) can be used in pointcut designators, ie. to specify classes and methods to wrap advices to&lt;br /&gt;
&lt;br /&gt;
Pointcut parameters. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AspectR lets a module wrap any number of methods in other classes (or objects) with the &amp;quot;advice&amp;quot; methods (in the lingo of Aspect/J) of the module.&lt;br /&gt;
&lt;br /&gt;
        require 'aspectr'&lt;br /&gt;
        include AspectR&lt;br /&gt;
        class MyAspect &amp;lt; Aspect&lt;br /&gt;
        def someAdviceMethod(method, object, exitstatus, *args)&lt;br /&gt;
             ...&lt;br /&gt;
        end&lt;br /&gt;
        ... some other advice methods ...&lt;br /&gt;
        end&lt;br /&gt;
        ma = MyAspect.new&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, ... methods to wrap...) or&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, /patternToWrap/) or&lt;br /&gt;
        AspectR.wrap_classes(ma, :preAdvice, :postAdvice,&lt;br /&gt;
       [Class1, Class2], ...methods to wrap...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advice methods are passed a variable number of parameters: the first is the name of the method currently being wrapped the second is the object receiving the method call the third is the exit/return status:&lt;br /&gt;
        Array with return value(s) if the method exited normally&lt;br /&gt;
        true if the method exited with an exception&lt;br /&gt;
        nil if the method hasn't yet exited (for preAdvice)&lt;br /&gt;
the rest are the arguments that were passed to the wrapped method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquarium is a framework that implements Aspect-Oriented Programming (AOP) for Ruby.&lt;br /&gt;
Aquarium provides a Domain Specific Language (DSL) with which you can express “aspectual” system behaviour in a modular way, i.e.,using a succinct language and without repeating yourself all over your code base!&lt;br /&gt;
&lt;br /&gt;
Imagine you want to trace all invocations of the public, instance methods in all classes whose names end with “Service”. Here’s how you can implement that behavior in Aquarium:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL before :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args log &amp;quot;Entering:    &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 after :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|log &amp;quot;Leaving:              &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The #before advice adds behavior that is invoked before each method is invoked, in this case, it logs a message with the name of the executing class and method, followed by the list of arguments passed to the method.&lt;br /&gt;
The #after advice adds similar behavior the is invoked after each method is invoked.&lt;br /&gt;
&lt;br /&gt;
A more succinct implementation of this behavior uses #around advice:&lt;br /&gt;
&lt;br /&gt;
 source: http://aquarium.rubyforge.org/index.html&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL around :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args| log &amp;quot;Entering: &lt;br /&gt;
 {join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result = join_point.proceed&lt;br /&gt;
 log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result  # block needs to return the result of the &amp;quot;proceed&amp;quot;!&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The special method #proceed invokes the advised method, passing it the args list (by default). For #around advice, you must call#proceed unless you specifically don’t want the original method called.&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
1. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References &amp;amp; Resources ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;br /&gt;
&lt;br /&gt;
[4]http://rubyforge.org/projects/aquarium/&lt;br /&gt;
&lt;br /&gt;
[5]http://aspectr.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
[6]http://aquarium.rubyforge.org/examples.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24528</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24528"/>
		<updated>2009-10-09T21:50:42Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* AspectR */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC.&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== AspectR == &lt;br /&gt;
&lt;br /&gt;
Aspect-oriented programming concepts to Ruby is provided by AspectR. Essentially it allows you to wrap code around existing methods in your classes. This can be a good thing (and even affect how you design your code) since it separates different concerns into different parts of the code. It is somewhat similar to AspectJ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Main features of AspectR (in AspectJ lingo): &lt;br /&gt;
&lt;br /&gt;
Join points:&lt;br /&gt;
&lt;br /&gt;
•	Object receives method/constructor call &lt;br /&gt;
&lt;br /&gt;
•	Field accessed (if access is via getter/setter meth) &lt;br /&gt;
&lt;br /&gt;
Advices: before (pre), after returning and after throwing (post)&lt;br /&gt;
&lt;br /&gt;
Advices can access:&lt;br /&gt;
&lt;br /&gt;
•	Object and method receiving call&lt;br /&gt;
&lt;br /&gt;
•	Arguments to call&lt;br /&gt;
&lt;br /&gt;
•	Return value&lt;br /&gt;
&lt;br /&gt;
•	exceptions raised&lt;br /&gt;
&lt;br /&gt;
Aspects: classes inheriting Aspect.&lt;br /&gt;
&lt;br /&gt;
Supports &amp;quot;abstract&amp;quot; Aspects and overriding between advices.&lt;br /&gt;
&lt;br /&gt;
Wildcards (really regexps) can be used in pointcut designators, ie. to specify classes and methods to wrap advices to&lt;br /&gt;
&lt;br /&gt;
Pointcut parameters. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AspectR lets a module wrap any number of methods in other classes (or objects) with the &amp;quot;advice&amp;quot; methods (in the lingo of Aspect/J) of the module.&lt;br /&gt;
&lt;br /&gt;
        require 'aspectr'&lt;br /&gt;
        include AspectR&lt;br /&gt;
        class MyAspect &amp;lt; Aspect&lt;br /&gt;
        def someAdviceMethod(method, object, exitstatus, *args)&lt;br /&gt;
             ...&lt;br /&gt;
        end&lt;br /&gt;
        ... some other advice methods ...&lt;br /&gt;
        end&lt;br /&gt;
        ma = MyAspect.new&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, ... methods to wrap...) or&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, /patternToWrap/) or&lt;br /&gt;
        AspectR.wrap_classes(ma, :preAdvice, :postAdvice,&lt;br /&gt;
       [Class1, Class2], ...methods to wrap...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advice methods are passed a variable number of parameters: the first is the name of the method currently being wrapped the second is the object receiving the method call the third is the exit/return status:&lt;br /&gt;
        Array with return value(s) if the method exited normally&lt;br /&gt;
        true if the method exited with an exception&lt;br /&gt;
        nil if the method hasn't yet exited (for preAdvice)&lt;br /&gt;
the rest are the arguments that were passed to the wrapped method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquarium is a framework that implements Aspect-Oriented Programming (AOP) for Ruby.&lt;br /&gt;
Aquarium provides a Domain Specific Language (DSL) with which you can express “aspectual” system behaviour in a modular way, i.e.,using a succinct language and without repeating yourself all over your code base!&lt;br /&gt;
&lt;br /&gt;
Imagine you want to trace all invocations of the public, instance methods in all classes whose names end with “Service”. Here’s how you can implement that behavior in Aquarium:&lt;br /&gt;
&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL before :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args log &amp;quot;Entering:    &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 after :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|log &amp;quot;Leaving:              &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The #before advice adds behavior that is invoked before each method is invoked, in this case, it logs a message with the name of the executing class and method, followed by the list of arguments passed to the method.&lt;br /&gt;
The #after advice adds similar behavior the is invoked after each method is invoked.&lt;br /&gt;
&lt;br /&gt;
A more succinct implementation of this behavior uses #around advice:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL around :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args| log &amp;quot;Entering: &lt;br /&gt;
 {join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result = join_point.proceed&lt;br /&gt;
 log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result  # block needs to return the result of the &amp;quot;proceed&amp;quot;!&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The special method #proceed invokes the advised method, passing it the args list (by default). For #around advice, you must call#proceed unless you specifically don’t want the original method called.&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
1. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References &amp;amp; Resources ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;br /&gt;
&lt;br /&gt;
[4]http://rubyforge.org/projects/aquarium/&lt;br /&gt;
&lt;br /&gt;
[5]http://aspectr.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
[6]http://aquarium.rubyforge.org/examples.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24527</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24527"/>
		<updated>2009-10-09T21:49:37Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* AspectR */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC.&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== AspectR == &lt;br /&gt;
&lt;br /&gt;
Aspect-oriented programming concepts to Ruby is provided by AspectR. Essentially it allows you to wrap code around existing methods in your classes. This can be a good thing (and even affect how you design your code) since it separates different concerns into different parts of the code. It is somewhat similar to AspectJ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Main features of AspectR (in AspectJ lingo): &lt;br /&gt;
&lt;br /&gt;
 Join points:&lt;br /&gt;
&lt;br /&gt;
•	Object receives method/constructor call &lt;br /&gt;
&lt;br /&gt;
•	Field accessed (if access is via getter/setter meth) &lt;br /&gt;
&lt;br /&gt;
Advices: before (pre), after returning and after throwing (post)&lt;br /&gt;
&lt;br /&gt;
Advices can access:&lt;br /&gt;
&lt;br /&gt;
•	Object and method receiving call&lt;br /&gt;
&lt;br /&gt;
•	Arguments to call&lt;br /&gt;
&lt;br /&gt;
•	Return value&lt;br /&gt;
&lt;br /&gt;
•	exceptions raised. &lt;br /&gt;
&lt;br /&gt;
Aspects: classes inheriting Aspect.&lt;br /&gt;
&lt;br /&gt;
 Supports &amp;quot;abstract&amp;quot; Aspects and overriding between advices.&lt;br /&gt;
&lt;br /&gt;
 Wildcards (really regexps) can be used in pointcut designators, ie. to specify classes and methods to wrap advice's to.&lt;br /&gt;
&lt;br /&gt;
 Pointcut parameters. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AspectR lets a module wrap any number of methods in other classes (or objects) with the &amp;quot;advice&amp;quot; methods (in the lingo of Aspect/J) of the module.&lt;br /&gt;
&lt;br /&gt;
        require 'aspectr'&lt;br /&gt;
        include AspectR&lt;br /&gt;
        class MyAspect &amp;lt; Aspect&lt;br /&gt;
        def someAdviceMethod(method, object, exitstatus, *args)&lt;br /&gt;
             ...&lt;br /&gt;
        end&lt;br /&gt;
        ... some other advice methods ...&lt;br /&gt;
        end&lt;br /&gt;
        ma = MyAspect.new&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, ... methods to wrap...) or&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, /patternToWrap/) or&lt;br /&gt;
        AspectR.wrap_classes(ma, :preAdvice, :postAdvice,&lt;br /&gt;
       [Class1, Class2], ...methods to wrap...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advice methods are passed a variable number of parameters: the first is the name of the method currently being wrapped the second is the object receiving the method call the third is the exit/return status:&lt;br /&gt;
        Array with return value(s) if the method exited normally&lt;br /&gt;
        true if the method exited with an exception&lt;br /&gt;
        nil if the method hasn't yet exited (for preAdvice)&lt;br /&gt;
the rest are the arguments that were passed to the wrapped method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquarium is a framework that implements Aspect-Oriented Programming (AOP) for Ruby.&lt;br /&gt;
Aquarium provides a Domain Specific Language (DSL) with which you can express “aspectual” system behaviour in a modular way, i.e.,using a succinct language and without repeating yourself all over your code base!&lt;br /&gt;
&lt;br /&gt;
Imagine you want to trace all invocations of the public, instance methods in all classes whose names end with “Service”. Here’s how you can implement that behavior in Aquarium:&lt;br /&gt;
&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL before :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args log &amp;quot;Entering:    &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 after :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|log &amp;quot;Leaving:              &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The #before advice adds behavior that is invoked before each method is invoked, in this case, it logs a message with the name of the executing class and method, followed by the list of arguments passed to the method.&lt;br /&gt;
The #after advice adds similar behavior the is invoked after each method is invoked.&lt;br /&gt;
&lt;br /&gt;
A more succinct implementation of this behavior uses #around advice:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL around :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args| log &amp;quot;Entering: &lt;br /&gt;
 {join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result = join_point.proceed&lt;br /&gt;
 log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result  # block needs to return the result of the &amp;quot;proceed&amp;quot;!&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The special method #proceed invokes the advised method, passing it the args list (by default). For #around advice, you must call#proceed unless you specifically don’t want the original method called.&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
1. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References &amp;amp; Resources ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;br /&gt;
&lt;br /&gt;
[4]http://rubyforge.org/projects/aquarium/&lt;br /&gt;
&lt;br /&gt;
[5]http://aspectr.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
[6]http://aquarium.rubyforge.org/examples.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24520</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24520"/>
		<updated>2009-10-09T21:47:23Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* AspectR */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC.&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== AspectR == &lt;br /&gt;
&lt;br /&gt;
Aspect-oriented programming concepts to Ruby is provided by AspectR. Essentially it allows you to wrap code around existing methods in your classes. This can be a good thing (and even affect how you design your code) since it separates different concerns into different parts of the code. It is somewhat similar to AspectJ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Main features of AspectR (in AspectJ lingo): &lt;br /&gt;
&lt;br /&gt;
 Join points:&lt;br /&gt;
&lt;br /&gt;
•	Object receives method/constructor call, and&lt;br /&gt;
&lt;br /&gt;
•	Field accessed (if access is via getter/setter meth) * Advices: before (pre), after returning and after throwing (post) * &lt;br /&gt;
&lt;br /&gt;
Aspects: classes inheriting Aspect.&lt;br /&gt;
&lt;br /&gt;
•	Supports &amp;quot;abstract&amp;quot; Aspects and overriding between advices. * Wildcards (really regexps) can be used in pointcut designators, ie. to specify classes and methods to wrap advice's to. * Pointcut parameters. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advices can access:&lt;br /&gt;
&lt;br /&gt;
•	Object and method receiving call,&lt;br /&gt;
&lt;br /&gt;
•	Arguments to call,&lt;br /&gt;
&lt;br /&gt;
•	Return values, and&lt;br /&gt;
&lt;br /&gt;
•	exceptions raised.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AspectR lets a module wrap any number of methods in other classes (or objects) with the &amp;quot;advice&amp;quot; methods (in the lingo of Aspect/J) of the module.&lt;br /&gt;
&lt;br /&gt;
        require 'aspectr'&lt;br /&gt;
        include AspectR&lt;br /&gt;
        class MyAspect &amp;lt; Aspect&lt;br /&gt;
        def someAdviceMethod(method, object, exitstatus, *args)&lt;br /&gt;
             ...&lt;br /&gt;
        end&lt;br /&gt;
        ... some other advice methods ...&lt;br /&gt;
        end&lt;br /&gt;
        ma = MyAspect.new&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, ... methods to wrap...) or&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, /patternToWrap/) or&lt;br /&gt;
        AspectR.wrap_classes(ma, :preAdvice, :postAdvice,&lt;br /&gt;
       [Class1, Class2], ...methods to wrap...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advice methods are passed a variable number of parameters: the first is the name of the method currently being wrapped the second is the object receiving the method call the third is the exit/return status:&lt;br /&gt;
        Array with return value(s) if the method exited normally&lt;br /&gt;
        true if the method exited with an exception&lt;br /&gt;
        nil if the method hasn't yet exited (for preAdvice)&lt;br /&gt;
the rest are the arguments that were passed to the wrapped method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquarium is a framework that implements Aspect-Oriented Programming (AOP) for Ruby.&lt;br /&gt;
Aquarium provides a Domain Specific Language (DSL) with which you can express “aspectual” system behaviour in a modular way, i.e.,using a succinct language and without repeating yourself all over your code base!&lt;br /&gt;
&lt;br /&gt;
Imagine you want to trace all invocations of the public, instance methods in all classes whose names end with “Service”. Here’s how you can implement that behavior in Aquarium:&lt;br /&gt;
&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL before :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args log &amp;quot;Entering:    &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 after :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|log &amp;quot;Leaving:              &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The #before advice adds behavior that is invoked before each method is invoked, in this case, it logs a message with the name of the executing class and method, followed by the list of arguments passed to the method.&lt;br /&gt;
The #after advice adds similar behavior the is invoked after each method is invoked.&lt;br /&gt;
&lt;br /&gt;
A more succinct implementation of this behavior uses #around advice:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL around :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args| log &amp;quot;Entering: &lt;br /&gt;
 {join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result = join_point.proceed&lt;br /&gt;
 log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result  # block needs to return the result of the &amp;quot;proceed&amp;quot;!&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The special method #proceed invokes the advised method, passing it the args list (by default). For #around advice, you must call#proceed unless you specifically don’t want the original method called.&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
1. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References &amp;amp; Resources ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;br /&gt;
&lt;br /&gt;
[4]http://rubyforge.org/projects/aquarium/&lt;br /&gt;
&lt;br /&gt;
[5]http://aspectr.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
[6]http://aquarium.rubyforge.org/examples.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24519</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24519"/>
		<updated>2009-10-09T21:47:06Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* AspectR */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC.&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== AspectR == &lt;br /&gt;
&lt;br /&gt;
Aspect-oriented programming concepts to Ruby is provided by AspectR. Essentially it allows you to wrap code around existing methods in your classes. This can be a good thing (and even affect how you design your code) since it separates different concerns into different parts of the code. It is somewhat similar to AspectJ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Main features of AspectR (in AspectJ lingo): &lt;br /&gt;
&lt;br /&gt;
* Join points:&lt;br /&gt;
&lt;br /&gt;
•	Object receives method/constructor call, and&lt;br /&gt;
&lt;br /&gt;
•	Field accessed (if access is via getter/setter meth) * Advices: before (pre), after returning and after throwing (post) * &lt;br /&gt;
&lt;br /&gt;
Aspects: classes inheriting Aspect.&lt;br /&gt;
&lt;br /&gt;
•	Supports &amp;quot;abstract&amp;quot; Aspects and overriding between advices. * Wildcards (really regexps) can be used in pointcut designators, ie. to specify classes and methods to wrap advice's to. * Pointcut parameters. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advices can access:&lt;br /&gt;
&lt;br /&gt;
•	Object and method receiving call,&lt;br /&gt;
&lt;br /&gt;
•	Arguments to call,&lt;br /&gt;
&lt;br /&gt;
•	Return values, and&lt;br /&gt;
&lt;br /&gt;
•	exceptions raised.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AspectR lets a module wrap any number of methods in other classes (or objects) with the &amp;quot;advice&amp;quot; methods (in the lingo of Aspect/J) of the module.&lt;br /&gt;
&lt;br /&gt;
        require 'aspectr'&lt;br /&gt;
        include AspectR&lt;br /&gt;
        class MyAspect &amp;lt; Aspect&lt;br /&gt;
        def someAdviceMethod(method, object, exitstatus, *args)&lt;br /&gt;
             ...&lt;br /&gt;
        end&lt;br /&gt;
        ... some other advice methods ...&lt;br /&gt;
        end&lt;br /&gt;
        ma = MyAspect.new&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, ... methods to wrap...) or&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, /patternToWrap/) or&lt;br /&gt;
        AspectR.wrap_classes(ma, :preAdvice, :postAdvice,&lt;br /&gt;
       [Class1, Class2], ...methods to wrap...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advice methods are passed a variable number of parameters: the first is the name of the method currently being wrapped the second is the object receiving the method call the third is the exit/return status:&lt;br /&gt;
        Array with return value(s) if the method exited normally&lt;br /&gt;
        true if the method exited with an exception&lt;br /&gt;
        nil if the method hasn't yet exited (for preAdvice)&lt;br /&gt;
the rest are the arguments that were passed to the wrapped method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquarium is a framework that implements Aspect-Oriented Programming (AOP) for Ruby.&lt;br /&gt;
Aquarium provides a Domain Specific Language (DSL) with which you can express “aspectual” system behaviour in a modular way, i.e.,using a succinct language and without repeating yourself all over your code base!&lt;br /&gt;
&lt;br /&gt;
Imagine you want to trace all invocations of the public, instance methods in all classes whose names end with “Service”. Here’s how you can implement that behavior in Aquarium:&lt;br /&gt;
&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL before :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args log &amp;quot;Entering:    &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 after :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|log &amp;quot;Leaving:              &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The #before advice adds behavior that is invoked before each method is invoked, in this case, it logs a message with the name of the executing class and method, followed by the list of arguments passed to the method.&lt;br /&gt;
The #after advice adds similar behavior the is invoked after each method is invoked.&lt;br /&gt;
&lt;br /&gt;
A more succinct implementation of this behavior uses #around advice:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL around :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args| log &amp;quot;Entering: &lt;br /&gt;
 {join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result = join_point.proceed&lt;br /&gt;
 log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result  # block needs to return the result of the &amp;quot;proceed&amp;quot;!&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The special method #proceed invokes the advised method, passing it the args list (by default). For #around advice, you must call#proceed unless you specifically don’t want the original method called.&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
1. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References &amp;amp; Resources ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;br /&gt;
&lt;br /&gt;
[4]http://rubyforge.org/projects/aquarium/&lt;br /&gt;
&lt;br /&gt;
[5]http://aspectr.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
[6]http://aquarium.rubyforge.org/examples.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24347</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24347"/>
		<updated>2009-10-09T19:59:51Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* Aspect R */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC.&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== ASPECTJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== APPENDIX ==&lt;br /&gt;
&lt;br /&gt;
1. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Aspect R == &lt;br /&gt;
&lt;br /&gt;
Aspect-oriented programming concepts to Ruby. Essentially it allows you to wrap code around existing methods in your classes. This can be a good thing (and even affect how you design your code) since it separates different concerns into different parts of the code. It is somewhat similar to AspectJ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Main features of AspectR (in AspectJ lingo): * Join points:&lt;br /&gt;
&lt;br /&gt;
•	object receives method/constructor call, and&lt;br /&gt;
&lt;br /&gt;
•	field accessed (if access is via getter/setter meth) * Advices: before (pre), after returning and after throwing (post) * &lt;br /&gt;
&lt;br /&gt;
Aspects: classes inheriting Aspect.&lt;br /&gt;
&lt;br /&gt;
•	supports &amp;quot;abstract&amp;quot; Aspects and overriding between advices. * Wildcards (really regexps) can be used in pointcut designators, ie. to specify classes and methods to wrap advice's to. * Pointcut parameters. &lt;br /&gt;
&lt;br /&gt;
Advices can access:&lt;br /&gt;
•	object and method receiving call,&lt;br /&gt;
&lt;br /&gt;
•	arguments to call,&lt;br /&gt;
&lt;br /&gt;
•	return values, and&lt;br /&gt;
&lt;br /&gt;
•	exceptions raised.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AspectR lets a module wrap any number of methods in other classes (or objects) with the &amp;quot;advice&amp;quot; methods (in the lingo of Aspect/J) of the module.&lt;br /&gt;
&lt;br /&gt;
        require 'aspectr'&lt;br /&gt;
        include AspectR&lt;br /&gt;
        class MyAspect &amp;lt; Aspect&lt;br /&gt;
        def someAdviceMethod(method, object, exitstatus, *args)&lt;br /&gt;
             ...&lt;br /&gt;
        end&lt;br /&gt;
        ... some other advice methods ...&lt;br /&gt;
        end&lt;br /&gt;
        ma = MyAspect.new&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, ... methods to wrap...) or&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, /patternToWrap/) or&lt;br /&gt;
        AspectR.wrap_classes(ma, :preAdvice, :postAdvice,&lt;br /&gt;
       [Class1, Class2], ...methods to wrap...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advice methods are passed a variable number of parameters: the first is the name of the method currently being wrapped the second is the object receiving the method call the third is the exit/return status:&lt;br /&gt;
        Array with return value(s) if the method exited normally&lt;br /&gt;
        true if the method exited with an exception&lt;br /&gt;
        nil if the method hasn't yet exited (for preAdvice)&lt;br /&gt;
the rest are the arguments that were passed to the wrapped method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquarium is a framework that implements Aspect-Oriented Programming (AOP) for Ruby.&lt;br /&gt;
Aquarium provides a Domain Specific Language (DSL) with which you can express “aspectual” system behaviour in a modular way, i.e.,using a succinct language and without repeating yourself all over your code base!&lt;br /&gt;
&lt;br /&gt;
Imagine you want to trace all invocations of the public, instance methods in all classes whose names end with “Service”. Here’s how you can implement that behavior in Aquarium:&lt;br /&gt;
&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL before :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args log &amp;quot;Entering:    &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 after :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|log &amp;quot;Leaving:              &lt;br /&gt;
 #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The #before advice adds behavior that is invoked before each method is invoked, in this case, it logs a message with the name of the executing class and method, followed by the list of arguments passed to the method.&lt;br /&gt;
The #after advice adds similar behavior the is invoked after each method is invoked.&lt;br /&gt;
&lt;br /&gt;
A more succinct implementation of this behavior uses #around advice:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL around :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args| log &amp;quot;Entering: &lt;br /&gt;
 {join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result = join_point.proceed&lt;br /&gt;
 log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result  # block needs to return the result of the &amp;quot;proceed&amp;quot;!&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The special method #proceed invokes the advised method, passing it the args list (by default). For #around advice, you must call#proceed unless you specifically don’t want the original method called!&lt;br /&gt;
&lt;br /&gt;
== REFERENCES ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24306</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24306"/>
		<updated>2009-10-09T19:48:11Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* Aspect R */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC.&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== ASPECTJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== APPENDIX ==&lt;br /&gt;
&lt;br /&gt;
1. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Aspect R == &lt;br /&gt;
&lt;br /&gt;
Aspect-oriented programming concepts to Ruby. Essentially it allows you to wrap code around existing methods in your classes. This can be a good thing (and even affect how you design your code) since it separates different concerns into different parts of the code. It is somewhat similar to AspectJ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Main features of AspectR (in AspectJ lingo): * Join points:&lt;br /&gt;
&lt;br /&gt;
•	object receives method/constructor call, and&lt;br /&gt;
&lt;br /&gt;
•	field accessed (if access is via getter/setter meth) * Advices: before (pre), after returning and after throwing (post) * &lt;br /&gt;
&lt;br /&gt;
Aspects: classes inheriting Aspect.&lt;br /&gt;
&lt;br /&gt;
•	supports &amp;quot;abstract&amp;quot; Aspects and overriding between advices. * Wildcards (really regexps) can be used in pointcut designators, ie. to specify classes and methods to wrap advice's to. * Pointcut parameters. &lt;br /&gt;
&lt;br /&gt;
Advices can access:&lt;br /&gt;
•	object and method receiving call,&lt;br /&gt;
&lt;br /&gt;
•	arguments to call,&lt;br /&gt;
&lt;br /&gt;
•	return values, and&lt;br /&gt;
&lt;br /&gt;
•	exceptions raised.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AspectR lets a module wrap any number of methods in other classes (or objects) with the &amp;quot;advice&amp;quot; methods (in the lingo of Aspect/J) of the module.&lt;br /&gt;
&lt;br /&gt;
        require 'aspectr'&lt;br /&gt;
        include AspectR&lt;br /&gt;
        class MyAspect &amp;lt; Aspect&lt;br /&gt;
        def someAdviceMethod(method, object, exitstatus, *args)&lt;br /&gt;
             ...&lt;br /&gt;
        end&lt;br /&gt;
        ... some other advice methods ...&lt;br /&gt;
        end&lt;br /&gt;
        ma = MyAspect.new&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, ... methods to wrap...) or&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, /patternToWrap/) or&lt;br /&gt;
        AspectR.wrap_classes(ma, :preAdvice, :postAdvice,&lt;br /&gt;
       [Class1, Class2], ...methods to wrap...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advice methods are passed a variable number of parameters: the first is the name of the method currently being wrapped the second is the object receiving the method call the third is the exit/return status:&lt;br /&gt;
        Array with return value(s) if the method exited normally&lt;br /&gt;
        true if the method exited with an exception&lt;br /&gt;
        nil if the method hasn't yet exited (for preAdvice)&lt;br /&gt;
the rest are the arguments that were passed to the wrapped method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquarium is a framework that implements Aspect-Oriented Programming (AOP) for Ruby.&lt;br /&gt;
Aquarium provides a Domain Specific Language (DSL) with which you can express “aspectual” system behaviour in a modular way, i.e.,using a succinct language and without repeating yourself all over your code base!&lt;br /&gt;
&lt;br /&gt;
Imagine you want to trace all invocations of the public, instance methods in all classes whose names end with “Service”. Here’s how you can implement that behavior in Aquarium:&lt;br /&gt;
        class ServiceTracer&lt;br /&gt;
	 include Aquarium::DSL&amp;lt;br&amp;gt;&lt;br /&gt;
	 before :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|&amp;lt;br&amp;gt;&lt;br /&gt;
	   log &amp;quot;Entering: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &amp;lt;br&amp;gt;&lt;br /&gt;
	 end&amp;lt;br&amp;gt;&lt;br /&gt;
	 after :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|&amp;lt;br&amp;gt;&lt;br /&gt;
	   log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &amp;lt;br&amp;gt;&lt;br /&gt;
	 end&amp;lt;br&amp;gt;&lt;br /&gt;
         end&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The #before advice adds behavior that is invoked before each method is invoked, in this case, it logs a message with the name of the executing class and method, followed by the list of arguments passed to the method.&lt;br /&gt;
The #after advice adds similar behavior the is invoked after each method is invoked.&lt;br /&gt;
&lt;br /&gt;
A more succinct implementation of this behavior uses #around advice:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 class ServiceTracer&lt;br /&gt;
 include Aquarium::DSL around :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args| log &amp;quot;Entering: &lt;br /&gt;
 {join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result = join_point.proceed&lt;br /&gt;
 log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
 result  # block needs to return the result of the &amp;quot;proceed&amp;quot;!&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The special method #proceed invokes the advised method, passing it the args list (by default). For #around advice, you must call#proceed unless you specifically don’t want the original method called!&lt;br /&gt;
&lt;br /&gt;
== REFERENCES ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24286</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24286"/>
		<updated>2009-10-09T19:36:27Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* Aspect R */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC.&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== ASPECTJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== APPENDIX ==&lt;br /&gt;
&lt;br /&gt;
1. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Aspect R == &lt;br /&gt;
&lt;br /&gt;
Aspect-oriented programming concepts to Ruby. Essentially it allows you to wrap code around existing methods in your classes. This can be a good thing (and even affect how you design your code) since it separates different concerns into different parts of the code. It is somewhat similar to AspectJ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Main features of AspectR (in AspectJ lingo): * Join points:&lt;br /&gt;
&lt;br /&gt;
•	object receives method/constructor call, and&lt;br /&gt;
&lt;br /&gt;
•	field accessed (if access is via getter/setter meth) * Advices: before (pre), after returning and after throwing (post) * &lt;br /&gt;
&lt;br /&gt;
Aspects: classes inheriting Aspect.&lt;br /&gt;
&lt;br /&gt;
•	supports &amp;quot;abstract&amp;quot; Aspects and overriding between advices. * Wildcards (really regexps) can be used in pointcut designators, ie. to specify classes and methods to wrap advice's to. * Pointcut parameters. &lt;br /&gt;
&lt;br /&gt;
Advices can access:&lt;br /&gt;
•	object and method receiving call,&lt;br /&gt;
&lt;br /&gt;
•	arguments to call,&lt;br /&gt;
&lt;br /&gt;
•	return values, and&lt;br /&gt;
&lt;br /&gt;
•	exceptions raised.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AspectR lets a module wrap any number of methods in other classes (or objects) with the &amp;quot;advice&amp;quot; methods (in the lingo of Aspect/J) of the module.&lt;br /&gt;
&lt;br /&gt;
        require 'aspectr'&lt;br /&gt;
        include AspectR&lt;br /&gt;
        class MyAspect &amp;lt; Aspect&lt;br /&gt;
        def someAdviceMethod(method, object, exitstatus, *args)&lt;br /&gt;
             ...&lt;br /&gt;
        end&lt;br /&gt;
        ... some other advice methods ...&lt;br /&gt;
        end&lt;br /&gt;
        ma = MyAspect.new&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, ... methods to wrap...) or&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, /patternToWrap/) or&lt;br /&gt;
        AspectR.wrap_classes(ma, :preAdvice, :postAdvice,&lt;br /&gt;
       [Class1, Class2], ...methods to wrap...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advice methods are passed a variable number of parameters: the first is the name of the method currently being wrapped the second is the object receiving the method call the third is the exit/return status:&lt;br /&gt;
        Array with return value(s) if the method exited normally&lt;br /&gt;
        true if the method exited with an exception&lt;br /&gt;
        nil if the method hasn't yet exited (for preAdvice)&lt;br /&gt;
the rest are the arguments that were passed to the wrapped method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquarium is a framework that implements Aspect-Oriented Programming (AOP) for Ruby.&lt;br /&gt;
Aquarium provides a Domain Specific Language (DSL) with which you can express “aspectual” system behaviour in a modular way, i.e.,using a succinct language and without repeating yourself all over your code base!&lt;br /&gt;
&lt;br /&gt;
Imagine you want to trace all invocations of the public, instance methods in all classes whose names end with “Service”. Here’s how you can implement that behavior in Aquarium:&lt;br /&gt;
        class ServiceTracer&lt;br /&gt;
	 include Aquarium::DSL&amp;lt;br&amp;gt;&lt;br /&gt;
	 before :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|&amp;lt;br&amp;gt;&lt;br /&gt;
	   log &amp;quot;Entering: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &amp;lt;br&amp;gt;&lt;br /&gt;
	 end&amp;lt;br&amp;gt;&lt;br /&gt;
	 after :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|&amp;lt;br&amp;gt;&lt;br /&gt;
	   log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &amp;lt;br&amp;gt;&lt;br /&gt;
	 end&amp;lt;br&amp;gt;&lt;br /&gt;
         end&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The #before advice adds behavior that is invoked before each method is invoked, in this case, it logs a message with the name of the executing class and method, followed by the list of arguments passed to the method.&lt;br /&gt;
The #after advice adds similar behavior the is invoked after each method is invoked.&lt;br /&gt;
&lt;br /&gt;
A more succinct implementation of this behavior uses #around advice:&lt;br /&gt;
           class ServiceTracer&lt;br /&gt;
	   include Aquarium::DSL&lt;br /&gt;
	   around :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|&lt;br /&gt;
	   log &amp;quot;Entering: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
	   result = join_point.proceed&lt;br /&gt;
	   log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
	   result  # block needs to return the result of the &amp;quot;proceed&amp;quot;!&lt;br /&gt;
	   end&lt;br /&gt;
           end&lt;br /&gt;
&lt;br /&gt;
The special method #proceed invokes the advised method, passing it the args list (by default). For #around advice, you must call#proceed unless you specifically don’t want the original method called!&lt;br /&gt;
&lt;br /&gt;
== REFERENCES ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24279</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24279"/>
		<updated>2009-10-09T19:33:44Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* Aspect R */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC.&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== ASPECTJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== APPENDIX ==&lt;br /&gt;
&lt;br /&gt;
1. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Aspect R == &lt;br /&gt;
&lt;br /&gt;
Aspect-oriented programming concepts to Ruby. Essentially it allows you to wrap code around existing methods in your classes. This can be a good thing (and even affect how you design your code) since it separates different concerns into different parts of the code. It is somewhat similar to AspectJ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Main features of AspectR (in AspectJ lingo): * Join points:&lt;br /&gt;
&lt;br /&gt;
•	object receives method/constructor call, and&lt;br /&gt;
&lt;br /&gt;
•	field accessed (if access is via getter/setter meth) * Advices: before (pre), after returning and after throwing (post) * &lt;br /&gt;
&lt;br /&gt;
Aspects: classes inheriting Aspect.&lt;br /&gt;
&lt;br /&gt;
•	supports &amp;quot;abstract&amp;quot; Aspects and overriding between advices. * Wildcards (really regexps) can be used in pointcut designators, ie. to specify classes and methods to wrap advice's to. * Pointcut parameters. &lt;br /&gt;
&lt;br /&gt;
Advices can access:&lt;br /&gt;
•	object and method receiving call,&lt;br /&gt;
&lt;br /&gt;
•	arguments to call,&lt;br /&gt;
&lt;br /&gt;
•	return values, and&lt;br /&gt;
&lt;br /&gt;
•	exceptions raised.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AspectR lets a module wrap any number of methods in other classes (or objects) with the &amp;quot;advice&amp;quot; methods (in the lingo of Aspect/J) of the module.&lt;br /&gt;
&lt;br /&gt;
        require 'aspectr'&lt;br /&gt;
        include AspectR&lt;br /&gt;
        class MyAspect &amp;lt; Aspect&lt;br /&gt;
        def someAdviceMethod(method, object, exitstatus, *args)&lt;br /&gt;
             ...&lt;br /&gt;
        end&lt;br /&gt;
        ... some other advice methods ...&lt;br /&gt;
        end&lt;br /&gt;
        ma = MyAspect.new&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, ... methods to wrap...) or&lt;br /&gt;
        ma.wrap(someClassorObject, :preAdvice, :postAdvice, /patternToWrap/) or&lt;br /&gt;
        AspectR.wrap_classes(ma, :preAdvice, :postAdvice,&lt;br /&gt;
       [Class1, Class2], ...methods to wrap...)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advice methods are passed a variable number of parameters: the first is the name of the method currently being wrapped the second is the object receiving the method call the third is the exit/return status:&lt;br /&gt;
        Array with return value(s) if the method exited normally&lt;br /&gt;
        true if the method exited with an exception&lt;br /&gt;
        nil if the method hasn't yet exited (for preAdvice)&lt;br /&gt;
the rest are the arguments that were passed to the wrapped method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquarium is a framework that implements Aspect-Oriented Programming (AOP) for Ruby.&lt;br /&gt;
Aquarium provides a Domain Specific Language (DSL) with which you can express “aspectual” system behaviour in a modular way, i.e.,using a succinct language and without repeating yourself all over your code base!&lt;br /&gt;
&lt;br /&gt;
Imagine you want to trace all invocations of the public, instance methods in all classes whose names end with “Service”. Here’s how you can implement that behavior in Aquarium:&lt;br /&gt;
        class ServiceTracer&lt;br /&gt;
	 include Aquarium::DSL&amp;lt;br&amp;gt;&lt;br /&gt;
	 before :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|&amp;lt;br&amp;gt;&lt;br /&gt;
	   log &amp;quot;Entering: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &amp;lt;br&amp;gt;&lt;br /&gt;
	 end&amp;lt;br&amp;gt;&lt;br /&gt;
	 after :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|&amp;lt;br&amp;gt;&lt;br /&gt;
	   log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &amp;lt;br&amp;gt;&lt;br /&gt;
	 end&amp;lt;br&amp;gt;&lt;br /&gt;
         end&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The #before advice adds behavior that is invoked before each method is invoked, in this case, it logs a message with the name of the executing class and method, followed by the list of arguments passed to the method.&lt;br /&gt;
The #after advice adds similar behavior the is invoked after each method is invoked.&lt;br /&gt;
&lt;br /&gt;
A more succinct implementation of this behavior uses #around advice:&lt;br /&gt;
           class ServiceTracer&lt;br /&gt;
	     include Aquarium::DSL&lt;br /&gt;
	    around :calls_to =&amp;gt; :all_methods, :in_types =&amp;gt; /Service$/ do |join_point, object, *args|&lt;br /&gt;
	    log &amp;quot;Entering: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
	    result = join_point.proceed&lt;br /&gt;
	    log &amp;quot;Leaving: #{join_point.target_type.name}##{join_point.method_name}: object = #{object}, args = #{args}&amp;quot; &lt;br /&gt;
	    result  # block needs to return the result of the &amp;quot;proceed&amp;quot;!&lt;br /&gt;
	    end&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
The special method #proceed invokes the advised method, passing it the args list (by default). For #around advice, you must call#proceed unless you specifically don’t want the original method called!&lt;br /&gt;
&lt;br /&gt;
== REFERENCES ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24089</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24089"/>
		<updated>2009-10-09T17:29:33Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* REFERENCES */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC.&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== ASPECTJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== APPENDIX ==&lt;br /&gt;
&lt;br /&gt;
1. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== REFERENCES ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
&lt;br /&gt;
[3] http://www.voelter.de/data/articles/aop/aop.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24087</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24087"/>
		<updated>2009-10-09T17:29:13Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* AspectJ */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
AOP has been implemented in different languages, among them Smalltalk and Java. The Java implementation of AOP is called AspectJ (TM) and has been created at Xerox PARC.&lt;br /&gt;
&lt;br /&gt;
Like any other aspect-oriented compiler, the AspectJ compiler includes a weaving phase that unambiguously resolves the cross-cutting between classes and aspects. AspectJ implements this additional phase by first weaving aspects with regular code and then calling the standard Java compiler. [[http://www.voelter.de/data/articles/aop/aop.html 3]]&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== ASPECTJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== APPENDIX ==&lt;br /&gt;
&lt;br /&gt;
1. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== REFERENCES ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24083</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24083"/>
		<updated>2009-10-09T17:27:18Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* REFERENCES */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== ASPECTJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== APPENDIX ==&lt;br /&gt;
&lt;br /&gt;
1. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== REFERENCES ==&lt;br /&gt;
&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24080</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24080"/>
		<updated>2009-10-09T17:26:53Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== ASPECTJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== APPENDIX ==&lt;br /&gt;
&lt;br /&gt;
1. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== REFERENCES ==&lt;br /&gt;
[1] http://onjava.com/onjava/2004/01/14/aop.html&lt;br /&gt;
[2] http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24075</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24075"/>
		<updated>2009-10-09T17:25:01Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* AspectJ */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== ASPECTJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== APPENDIX ==&lt;br /&gt;
&lt;br /&gt;
1. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24072</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24072"/>
		<updated>2009-10-09T17:23:21Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* '''APPENDIX''' */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
== ASPECTJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== APPENDIX ==&lt;br /&gt;
&lt;br /&gt;
1. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24070</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24070"/>
		<updated>2009-10-09T17:23:02Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* '''APPENDIX''' */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
== ASPECTJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''APPENDIX''' ==&lt;br /&gt;
&lt;br /&gt;
1. For more information on AJDT, click here : http://eclipse.org/ajdt/&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24069</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24069"/>
		<updated>2009-10-09T17:22:46Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
== ASPECTJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''APPENDIX''' ==&lt;br /&gt;
&lt;br /&gt;
1. FOR more information on AJDT, click here : http://eclipse.org/ajdt/&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24068</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24068"/>
		<updated>2009-10-09T17:20:53Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* Terminologies used in Aspect Oriented Programming */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers. [[http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm 2]]&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
== ASPECTJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24066</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24066"/>
		<updated>2009-10-09T17:20:05Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* ''' Aspect Oriented Programming - An Introduction''' */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own. [[http://onjava.com/onjava/2004/01/14/aop.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers,&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
== ASPECTJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24059</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24059"/>
		<updated>2009-10-09T17:16:23Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* Terminologies used in Aspect Oriented Programming */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Here are the definitions of some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
&lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
&lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers,&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
== ASPECTJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24056</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24056"/>
		<updated>2009-10-09T17:15:00Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* ASPECTJ Plugin tool */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here are some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers, &lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
== ASPECTJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf or http://www.eclipse.org/ajdt/EclipseCon2006/&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24055</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=24055"/>
		<updated>2009-10-09T17:13:50Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* AspectJ */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here are some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers, &lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;br /&gt;
&lt;br /&gt;
== ASPECTJ Plugin tool ==&lt;br /&gt;
&lt;br /&gt;
The AspectJ Development Tools (AJDT) project provides Eclipse platform based tool with AspectJ.&lt;br /&gt;
AspectJ is run under the same open source collective as the Eclipse project and provides the most advanced AspectJ plug-in for an IDE. The AspectJ Development Tools (AJDT) for Eclipse not only provides Eclipse users with tools to code AspectJ applications, but also includes a visualizer to show you where your aspects will be applied. To know how to install this tool AJDT, click here http://onjava.com/onjava/2004/11/24/aspect_j.pdf&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=23947</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=23947"/>
		<updated>2009-10-09T15:44:53Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== ''' Aspect Oriented Programming - An Introduction''' ==&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems began to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Terminologies used in Aspect Oriented Programming ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here are some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers, &lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== AspectJ ==&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  source: http://www.developer.com/design/article.php/3308941/Aspect-Oriented-Programming.htm&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=23935</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=23935"/>
		<updated>2009-10-09T15:40:13Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems begun to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ASPECTJ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here are some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers, &lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;br /&gt;
&lt;br /&gt;
From 1, we see that an aspect is defined in the same way as a Java class. Just like any Java class, an aspect may have member variables and methods. In addition, it may include pointcuts, advices, and introductions.&lt;br /&gt;
In lines 2 and 3, we specify the place in the TestClass code where our modification will take place.&lt;br /&gt;
In AspectJ, 'join points' represent well-defined points in a program's execution. Typical join points in AspectJ include method/constructor calls, method/constructor execution, field get and set, exception handler execution, and static and dynamic initialization. In the  example above, two join points are used :the call to TestClass.sayHello and TestClass.sayAnyThing methods.&lt;br /&gt;
Pointcut is a language construct that picks out a set of join points based on defined criteria. The criteria can be explicit function names, or function names specified by wildcards.&lt;br /&gt;
 public pointcut sayMethodCall (): call (public void&lt;br /&gt;
                                        TestClass.say*() );&lt;br /&gt;
&lt;br /&gt;
In this line, we define a pointcut- sayMethodCall, which picks out any call to the TestClass.sayHello method. It also picks out any public TestClass method with zero arguments and a name that starts with 'say' (for example, TestClass.sayBye).&lt;br /&gt;
Pointcuts are used in the definition of advice. An advice is used to define additional code to be executed before, after, or around join points. In our example, lines 4–6 and 7–9 define two advices that will be executed before and after the first pointcut. Lines 10–15 implement an advice associated with the second pointcut and are used to set a precondition before the execution of the TestClass.sayAnyThing method.&lt;br /&gt;
Thus pointcuts and advice let us affect the dynamic execution of a program.&lt;br /&gt;
Introduction allows aspects to modify the static structure of a program. By using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=23933</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=23933"/>
		<updated>2009-10-09T15:38:49Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems begun to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ASPECTJ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here are some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers, &lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
This is the existing Java code called TestClass.java. Now if we want to make use of aspects to make two modifications such as:&lt;br /&gt;
1.We would like to print a message before and after any call to the TestClass.sayHello() method. &lt;br /&gt;
2.We need to test that the argument of the TestClass.sayAnyThing() method is at least three characters. &lt;br /&gt;
&lt;br /&gt;
Here  is the AspectJ implementation&lt;br /&gt;
  1: public aspect MyAspect {&lt;br /&gt;
  2:   public pointcut sayMethodCall (): call (public void TestClass.say*() );&lt;br /&gt;
  3:   public pointcut sayMethodCallArg (String str): call&lt;br /&gt;
                     (public void TestClass.sayAnyThing (String))&lt;br /&gt;
                     &amp;amp;&amp;amp; args(str);&lt;br /&gt;
  4:   before(): sayMethodCall() {&lt;br /&gt;
  5:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot;start...&amp;quot; );&lt;br /&gt;
  6:   }&lt;br /&gt;
  7:   after(): sayMethodCall() {&lt;br /&gt;
  8:   System.out.println(&amp;quot;\n TestClass.&amp;quot; +&lt;br /&gt;
       thisJoinPointStaticPart.getSignature().getName() +&lt;br /&gt;
       &amp;quot; end...&amp;quot;);&lt;br /&gt;
  9:   }&lt;br /&gt;
&lt;br /&gt;
  10:   before(String str): sayMethodCallArg(str) {&lt;br /&gt;
  11:     if (str .length() &amp;lt; 3) {&lt;br /&gt;
  12:     System.out.println (&amp;quot;Error: I can't say words less than 3&lt;br /&gt;
                             characters&amp;quot;);&lt;br /&gt;
  13:     return;&lt;br /&gt;
  14:     }&lt;br /&gt;
  15:   }&lt;br /&gt;
  16: }&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=23928</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=23928"/>
		<updated>2009-10-09T15:36:15Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems begun to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ASPECTJ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here are some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers, &lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=23927</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=23927"/>
		<updated>2009-10-09T15:35:39Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems begun to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ASPECTJ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here are some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers, &lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;br /&gt;
&lt;br /&gt;
Let's consider the following example to understand this better.&lt;br /&gt;
 public class TestClass {&lt;br /&gt;
  public void sayHello () {&lt;br /&gt;
    System.out.println (&amp;quot;Hello, AOP&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void sayAnyThing (String s) {&lt;br /&gt;
    System.out.println (s);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    sayHello ();&lt;br /&gt;
    sayAnyThing (&amp;quot;ok&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=23923</id>
		<title>CSC/ECE 517 Fall 2009/wiki29 VB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki29_VB&amp;diff=23923"/>
		<updated>2009-10-09T15:34:02Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
When Object-Oriented (OO) programming was entering into the field of software development, it changed the way how software was developed. The software systems begun to be viewed as groups of entities and the interaction between those entities, which allowed them to tackle larger, more complicated systems and develop them in less time than ever before. However, OO programming is static, and a thus a change in requirements could have a brought a major impact on development time lines. &lt;br /&gt;
&lt;br /&gt;
Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops. &lt;br /&gt;
&lt;br /&gt;
For example, we develop a  web application where a servlet accepts the values of an HTML form, binds them to an object, passes them into the application to be processed, and then returns a response to the user. This basic functionality of the servlet may be very simple, and can be fulfilled with  minimum amount of code.  But, by the time secondary requirements such as exception handling, security, and logging have been implemented , the size of the code increases to about three times of original. Having said that, it is not mandatory for the servlet to know about the logging or security mechanisms being used, and hence can be called as secondary requirements. Its primary function is to just accept input and process it. &lt;br /&gt;
&lt;br /&gt;
Using AOP , we can dynamically modify our static model to include the code required to fulfill the secondary requirements without having to modify the original static model. We can also keep this additional code in a single location rather than having to scatter it across the existing model, as we would have to if we were using OO on its own.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ASPECTJ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here are some of the standard terms that would be required to understand AOP concepts.&lt;br /&gt;
1.Cross-cutting concerns: Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. For example, we may want to add logging to classes within the data-access layer and also to classes in the UI layer whenever a thread enters or exits a method. Even though the primary functionality of each class is very different, the code needed to perform the secondary functionality is often identical.&lt;br /&gt;
2.Advice: Advice is the extra code that we want to add to our already existing model. &lt;br /&gt;
3.Point-cut: Point-cut is the point of execution in the application at which cross-cutting concern needs to be applied. &lt;br /&gt;
4.Aspect: Aspect is the combination of the point-cut and the advice.&lt;br /&gt;
The other terms that appear often in AOP are introductions (where interfaces/methods/fields can be added to existing classes). These hold tremendous potential for developers, &lt;br /&gt;
&lt;br /&gt;
Just as the important facets of OOP are inheritance, encapsulation, and polymorphism, the components of AOP are join points, pointcut, advice, and introduction.&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b12_AV&amp;diff=22407</id>
		<title>CSC/ECE 517 Fall 2009/wiki1b12 AV</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b12_AV&amp;diff=22407"/>
		<updated>2009-09-29T03:21:21Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* C# */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;XUnit in general, is only one kind of testing framework for object oriented languages. This page talks about the major testing frameworks available for the major object oriented languages such as Java, C++, C#,Python, Ruby and C#. Comparisons have been made wherever possible between the major frameworks available in each language. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Java Testing Frameworks =&lt;br /&gt;
&lt;br /&gt;
Plenty of testing framework exist for Java. JUnit has been the de facto standard for unit testing. However, other frameworks such as TestNG, JTIGER have been built to address various faults and deficiencies with JUnit.  Our primary objective is to compare the various testing frameworks that exist for object oriented languages based on the primary purpose of the framework, features, the platforms on which they operate, etc and thus help in picking up the best testing framework that fits in a particular suitable environment.&lt;br /&gt;
This article DOES NOT introduce JUnit or XUnit. For information on JUnit and XUnit, please refer to the http://www.junit.org or [[http://en.wikipedia.org/wiki/Junit '''APPENDIX 1''']] and [[http://en.wikipedia.org/wiki/XUnit '''APPENDIX 2''']] &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== TestNG Framework ==&lt;br /&gt;
&lt;br /&gt;
TestNG is a testing framework which can help to meet a broad range of testing such as unit testing, integration testing, functional testing, end-to -end testing. (For definition and more information on the different kinds of testing, refer to [[http://en.wikipedia.org/wiki/Unit_testing ''' APPENDIX 3''']] and [[http://en.wikipedia.org/wiki/Integration_testing ''' APPENDIX 4''']]&lt;br /&gt;
&lt;br /&gt;
To write a TestNG test, we need to:&lt;br /&gt;
Write the business logic of the test, and insert the TestNG annotations in them.&lt;br /&gt;
Add the information about our test (such as the class name, the groups we wish to run, etc) in a testing.xml file or in build.xml. &lt;br /&gt;
Run the test.&lt;br /&gt;
TestNG supports data driven testing.(Data-driven testing is a methodology used in Test automation where test scripts are executed and verified based on the data values stored in one or more central data sources or databases. For a detailed description on data driven testing click here: http://en.wikipedia.org/wiki/Data-driven_testing  )&lt;br /&gt;
&lt;br /&gt;
TestNG is invoked in several different ways: &lt;br /&gt;
With a testing.xml file&lt;br /&gt;
ANT&lt;br /&gt;
Command line&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is possible to group the test methods of TestNG.  We can declare methods that belong to these groups and specify groups that contain other groups. It is very flexible as it can help in choosing one set of regular expression and excluding the other sets. This splits the various test groups and there is no need to recompile again if we want to run two different tests back to back.&lt;br /&gt;
&lt;br /&gt;
Requirements:&lt;br /&gt;
JDK 1.4, 1.5&lt;br /&gt;
Invoked in many environments such as command line, ant, ECLIPSE, IDEA, MAVEN, etc&lt;br /&gt;
&lt;br /&gt;
The annotations available in TestNG can be found at:&lt;br /&gt;
http://testng.org/doc/documentation-main.html#annotations&lt;br /&gt;
&lt;br /&gt;
TestNG is inspired from JUnit and Nunit, with additional functionalities such as Flexible test configuration, support for data driven testing, etc.[[http://testng.org/doc/documentation-main.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Cactus ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Cactus is a test framework for testing server-side java code such as Servlets, EJB, etc. It extends J Unit.&lt;br /&gt;
Cactus implements an in-container strategy which means that tests are executed inside the container. &lt;br /&gt;
The Cactus testing unit can be viewed as a system that consists of the following components:&lt;br /&gt;
 &lt;br /&gt;
--Cactus Framework:  This provides the API to write Cactus tests. &lt;br /&gt;
&lt;br /&gt;
--Cactus Integration Modules: They are front ends and frameworks that provide easy ways of using the Cactus Framework. Eg: Eclipse plugin&lt;br /&gt;
&lt;br /&gt;
--Cactus Samples: They demonstrate how to write Cactus tests and how to use a few Integration Modules. [[http://jakarta.apache.org/cactus/index.html 2]]&lt;br /&gt;
&lt;br /&gt;
A useful testing framework provided by Cactus is  integration unit testing.  The tests written for this framework will exercise the interactions with the container. Cactus also provides other frameworks such as code logic unit testing, functional unit testing.&lt;br /&gt;
&lt;br /&gt;
Cactus was developed to fit only integration unit testing with the idea that it is much easier to have to write tests for a single framework than for several. It is believed that Cactus provides a middle ground that provides a high confidence that your code will run when deployed .[[http://jakarta.apache.org/cactus/index.html 2]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To know how it works, click here :&lt;br /&gt;
http://jakarta.apache.org/cactus/how_it_works.html&lt;br /&gt;
&lt;br /&gt;
== '''COMPARISON BETWEEN JUnit,TestNG and Cactus frameworks''' [[http://junit.sourceforge.net/doc/cookbook/cookbook.htm 3]] ==&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''JUnit4'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''TestNG'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Cactus'''&lt;br /&gt;
|-&lt;br /&gt;
| Supporting Type of Testing||Suitable more for Unit testing||Supports Unit testing,Functional testing, end-to-end testing, integration testing ||Primarily unit testing. Also have frameworks for code logic unit testing , functional logic unit testing&lt;br /&gt;
|-&lt;br /&gt;
| Conventions||Rigid  ||Flexible||Not as flexible as TestNG&lt;br /&gt;
|-&lt;br /&gt;
| Derived from JUnit||Yes, from the previous versions||Inspired from Junit,with  added functionalities ||Extends JUnit&lt;br /&gt;
|-&lt;br /&gt;
| Flexibility for large suites||Not flexible for large test suites, ||Flexible for running large test suites of code  and thus one test\'s failure shouldn\'t mean having to rerun a suite of thousands. || No, it is suitable for unit testing.&lt;br /&gt;
|-&lt;br /&gt;
| Suitable for ||Best for a single object||Best for a higher level testing||Best for server-side java code such as Servlets, EJB, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Works with||Command line, ANT,ECLIPSE||Command line,ANT, ECLIPSE, IDEA,MAVEN||ANT&lt;br /&gt;
|-&lt;br /&gt;
| ||||||&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== An example comparing JUNIT 4 and TestNG ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''JUnit 4  v/s TestNG'''&lt;br /&gt;
&lt;br /&gt;
(source: http://www.ibm.com/developerworks/java/library/j-cq08296/) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The frameworks differ is in their core design. JUnit has always been an effective unit-testing framework, meaning that it was built to facilitate testing single objects. TestNG, on the other hand, was built to address testing at higher levels, and consequently, has some features not available in JUnit&lt;br /&gt;
 &lt;br /&gt;
JUnit 4 makes clever use of annotations. JUnit no longer requires you to define a test as a method whose name starts with test, and we can now run fixtures just once as opposed to for each test.  However TestNG established itself as an annotations-based framework long before Junit 4. TestNG pioneered testing with annotations in Java programming, which made it a formidable alternative to JUnit. [[http://www.ibm.com/developerworks/java/library/j-cq08296 4]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Sample J Unit 4 code&lt;br /&gt;
&lt;br /&gt;
 package test.com.acme.dona.dep;&lt;br /&gt;
 import static org.junit.Assert.assertEquals;&lt;br /&gt;
 import static org.junit.Assert.assertNotNull;&lt;br /&gt;
 import org.junit.BeforeClass;&lt;br /&gt;
 import org.junit.Test;&lt;br /&gt;
 public class DependencyFinderTest {&lt;br /&gt;
 private static DependencyFinder finder;&lt;br /&gt;
 @BeforeClass&lt;br /&gt;
 public static void init() throws Exception {&lt;br /&gt;
  finder = new DependencyFinder();&lt;br /&gt;
 }&lt;br /&gt;
 @Test&lt;br /&gt;
 public void verifyDependencies() &lt;br /&gt;
  throws Exception {&lt;br /&gt;
   String targetClss = &lt;br /&gt;
     &amp;quot;test.com.acme.dona.dep.DependencyFind&amp;quot;;&lt;br /&gt;
 Filter[] filtr = new Filter[] { &lt;br /&gt;
      new RegexPackageFilter(&amp;quot;java|junit|org&amp;quot;)};&lt;br /&gt;
 Dependency[] deps = &lt;br /&gt;
      finder.findDependencies(targetClss, filtr);&lt;br /&gt;
 assertNotNull(&amp;quot;deps was null&amp;quot;, deps);&lt;br /&gt;
   assertEquals(&amp;quot;should be 5 large&amp;quot;, 5, deps.length);   &lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
 (source: http://www.ibm.com/developerworks/java/library/j-cq08296/)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Sample TestNG code&lt;br /&gt;
&lt;br /&gt;
 package test.com.acme.dona.dep;&lt;br /&gt;
 import static org.testng.Assert.assertEquals;&lt;br /&gt;
 import static org.testng.Assert.assertNotNull;&lt;br /&gt;
 import org.testng.annotations.BeforeClass;&lt;br /&gt;
 import org.testng.annotations.Configuration;&lt;br /&gt;
 import org.testng.annotations.Test;&lt;br /&gt;
 public class DependencyFinderTest {&lt;br /&gt;
 private DependencyFinder finder;&lt;br /&gt;
 @BeforeClass&lt;br /&gt;
 private void init(){&lt;br /&gt;
  this.finder = new DependencyFinder();&lt;br /&gt;
 }&lt;br /&gt;
 @Test&lt;br /&gt;
 public void verifyDependencies() &lt;br /&gt;
  throws Exception {&lt;br /&gt;
   String targetClss = &lt;br /&gt;
     &amp;quot;test.com.acme.dona.dep.DependencyFind&amp;quot;;&lt;br /&gt;
   Filter[] filtr = new Filter[] { &lt;br /&gt;
      new RegexPackageFilter(&amp;quot;java|junit|org&amp;quot;)};&lt;br /&gt;
   Dependency[] deps = &lt;br /&gt;
      finder.findDependencies(targetClss, filtr);&lt;br /&gt;
   assertNotNull(deps, &amp;quot;deps was null&amp;quot; );&lt;br /&gt;
   assertEquals(5, deps.length, &amp;quot;should be 5 large&amp;quot;);           &lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
 (source: http://www.ibm.com/developerworks/java/library/j-cq08296/)&lt;br /&gt;
&lt;br /&gt;
Both the codes may look a lot similar. However TestNG coding conventions are more flexible than JUnit 4.&lt;br /&gt;
&lt;br /&gt;
JUnit forces us to declare the @BeforeClass (See [[http://junit.sourceforge.net/javadoc_40/org/junit/BeforeClass.html '''APPENDIX 5''']] for more information)  method as static, which consequently requires us to also declare the fixture, finder, as static. We also have to declare the init() method as public. Looking at the TestNG code, you can find that such conventions aren't required. Its init() method is neither static nor public. &lt;br /&gt;
Flexibility has been one of the strong points of TestNG right from the start. JUnit works well for a unit of code, whereas TestNG is better suited for high-level testing. Its flexibility is especially useful with large test suites.[[http://www.ibm.com/developerworks/java/library/j-cq08296 4]]&lt;br /&gt;
&lt;br /&gt;
== Some other JAVA testing units [[http://www.opensourcetesting.org/unit_java.php 5]]  ==&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''JEasyTest'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''J2ME Unit Testing Toolkit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Jailer'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Mockrunner'''&lt;br /&gt;
|-&lt;br /&gt;
| Features||Generates coverage report Allows virtual mock object||Is a  Java 2 Micro Edition (J2ME) library containing a unit testing framework for J2ME||Does test data exporting.  JDBC agnostic  Generates DbUnit datasets, hierarchically structured XML, and topologically sorted SQL-DML.||A lightweight framework for unit testing applications in the J2EE environment.&lt;br /&gt;
|-&lt;br /&gt;
| Integrates with:||ECLIPSE 3.3||ANT ||Platform Independent||OS independent&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Testing frameworks for C++   =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When it comes to unit testing in Java, a unanimous choice would be JUnit. However for C++, there is no one clear winner.  CppUnit is the most widely used tool for C++ which is a part of the XUnit family.&lt;br /&gt;
&lt;br /&gt;
Following is a few basic factors to judge a good testing unit in C++ [[http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle 6]] &lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Features'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''CppUnit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''BOOST.test'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''CxxUnit'''&lt;br /&gt;
|-&lt;br /&gt;
| Minimal amount of work needed to add new tests ||No, and thus a major downfall.||Yes||Yes, very good.&lt;br /&gt;
|-&lt;br /&gt;
| Easy to modify and port ||Medium||Medium||Simplest&lt;br /&gt;
|-&lt;br /&gt;
| Supports setup/teardown steps ||Yes||||Best&lt;br /&gt;
|-&lt;br /&gt;
| Handles exceptions and crashes well.||Yes||Yes, above others||Great support.&lt;br /&gt;
|-&lt;br /&gt;
| Good assert functionality.||Pretty decent.||Yes||Best&lt;br /&gt;
|-&lt;br /&gt;
| Supports different outputs. ||Yes. Comes with IDE friendly output.||Probably, Not trivial to change.||Yes&lt;br /&gt;
|-&lt;br /&gt;
| Supports  suites||Yes.||Yes, but with a big catch. ||Yes&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CppUnit passes most of the above tests , except for the first point and thus needs a lot of code typing.&lt;br /&gt;
Boost.Test isn’t exclusively a unit-testing framework, and is not X Unit based.&lt;br /&gt;
&lt;br /&gt;
Out of the above three , cxxUnit turns out to be a favourite.&lt;br /&gt;
&lt;br /&gt;
It comes close to the requirements of an ideal framework by leveraging the power of an external scripting language. It provides some nifty advanced features and great assert functionality. It does require the use of a scripting language as part of the build process, so those uncomfortable with that requirement, might want to look at one of the other two frameworks.&lt;br /&gt;
&lt;br /&gt;
For work restricted to the PC,  where modifying the framework is not required Boost.Test could  be a very good choice.&lt;br /&gt;
CppUnit , which has come a long way in years is a solid, complete framework  The major drawbacks are the relative verbosity for adding new tests and fixtures. [[http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle 6]]&lt;br /&gt;
&lt;br /&gt;
= Python =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Doctest''': It is a simple, ingenuine technology that allows you to write a narrative in a document which can directly be executed as a test. It is included in Python as a module.&lt;br /&gt;
&lt;br /&gt;
Although doctest makes testing code readable for non-programmers ,the simplicity of a narrative test like doctest is accompanied by it’s own flaws .Some of the disadvantages of using doctest are&lt;br /&gt;
&lt;br /&gt;
•	These tests are difficult to handle in case of failures as they are more generic. Specific tests are narrower and better in communicating intent and ensuring coverage.&lt;br /&gt;
&lt;br /&gt;
•	The test code is executed in a special way thus making it difficult to reason about how it will be executed. It is also harder to program around the tests.&lt;br /&gt;
&lt;br /&gt;
•	It is actually difficult to get an outline of the tests at glance. There’s no tool that can give an overview of the unit tests in a doc test file [[http://en.wikipedia.org/wiki/Doctest 7]].&lt;br /&gt;
&lt;br /&gt;
An detailed information about doctest with thorough examples can be read at http://docs.python.org/library/doctest.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Unittest''': Unittest are more specific tests which are more functional in nature allowing it to be written for individual functions or the class as a whole. &lt;br /&gt;
&lt;br /&gt;
The fact that Unittest is based on jUnit makes people with the xUnit familiarity pick it up really quick hence it is more Java based than python .It has been introduced in the Python’s library since version 2.1 &lt;br /&gt;
&lt;br /&gt;
The disadvantages of using the unit test are &lt;br /&gt;
&lt;br /&gt;
•	The tests have a different look and feel with respect to the code under test&lt;br /&gt;
&lt;br /&gt;
•	The assertions used in the text use custom syntax which makes it difficult&lt;br /&gt;
&lt;br /&gt;
•	The test code is difficult to understand compared to the Doctest and the strong basis on jUnit makes it difficult for the pure Python coders [[http://en.wikipedia.org/wiki/Unit_testing 8]]&lt;br /&gt;
&lt;br /&gt;
A detailed information about doctest with thorough examples can be read at http://docs.python.org/library/unittest.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Doctest vs Unittest'''&lt;br /&gt;
&lt;br /&gt;
Here we compare simple features of both the tests thus giving us an idea of which one to use based on the requirement&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''doctest'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''unittest'''&lt;br /&gt;
|-&lt;br /&gt;
| '''Simplicity'''||Best suited for novice programmers||A little complex to use specially if unaware of Junit&lt;br /&gt;
|-&lt;br /&gt;
| '''Documentation'''||Better Narratives||Tests have little or no comments&lt;br /&gt;
|-&lt;br /&gt;
| '''Comprehensive testing'''||Doctests get clutterd for comprehensive tests and thus less readable||Best suited for comprehensive tests&lt;br /&gt;
|-&lt;br /&gt;
| '''Flexibility and Control'''||Less flexible||More flexible&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Ruby =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The basic testing framework for RUBY is xUnit . There are some frameworks which have evolved over the years which include RSpec, Trantula, Flog, RunCodeRun, Cucumber etc. We’ll talk about each of them in brief&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Testing Framework'''&lt;br /&gt;
| style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Description'''&lt;br /&gt;
|-&lt;br /&gt;
| '''Rspec[[http://www.elctech.com/tutorials/rspec-tutorial 9]]'''||It is Behavior Driven Development whose basic features are&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Behavior counts first, testing follows&lt;br /&gt;
|-&lt;br /&gt;
| ||·         It focuses more on business values&lt;br /&gt;
|-&lt;br /&gt;
| ||·         It’s more about getting the words right rather than just writing the test first&lt;br /&gt;
|-&lt;br /&gt;
| ||Advantages:&lt;br /&gt;
|-&lt;br /&gt;
| ||·         These are extremely easy to read and makes sense to a non-programmer&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Rspec lets you unit test while also providing mocking and stubbing support&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Rspec can help with the coverage tests using Rcov&lt;br /&gt;
|-&lt;br /&gt;
| ||·         One can also perform integration test using Rspec &lt;br /&gt;
|-&lt;br /&gt;
| ||Disadvantages:&lt;br /&gt;
|-&lt;br /&gt;
| ||·         It involves a lot of behind the scene metaprogramming which makes the tests very difficult to understand&lt;br /&gt;
|-&lt;br /&gt;
| ||A simple Rspec example can be read at http://rspec.info/&lt;br /&gt;
|-&lt;br /&gt;
| '''Cucumber[[http://www.rubyinside.com/cucumber-the-latest-in-ruby-testing-1342.html 10]]'''||Cucumber, the latest addition to the Rspec family allows one to execute documentation written in plain text(known as ‘stories’)&lt;br /&gt;
|-&lt;br /&gt;
| ||A very good example of writing a test in cucumber can be read at http://cukes.info/&lt;br /&gt;
|-&lt;br /&gt;
| ||&lt;br /&gt;
|-&lt;br /&gt;
| '''Tarantula[[http://www.ruby-forum.com/topic/144083 11]]'''||Tarantula is a Rail’s plugin that produces a detailed report describing the URL’s that it has crawled across and the responses that it received from each one of them.&lt;br /&gt;
|-&lt;br /&gt;
| ||Tarantula\'s functionality somewhat overlaps with the on site testing, particularly if you are practicing test-driven development (TDD). Tarantula runs against your actual Web site thereby helping you to identify the problems associated with your production server, user-generated data, and HTML compliance.&lt;br /&gt;
&lt;br /&gt;
A well explained example can be seen at http://www.railslodge.com/plugins/959-tarantula&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| '''Flog[[http://www.brynary.com/2007/9/13/scourging-your-ruby-code-with-flog 12]]'''||Flog is a tool which gives you a profile of your code’s complexity. It can given the complexity pertaining to each method in your code. One can also set threshold for each method using flog &lt;br /&gt;
|-&lt;br /&gt;
| ||The complexity of a code can be important to &lt;br /&gt;
|-&lt;br /&gt;
| ||·         Find the bugs as they are highly probable in complex code areas&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Complex codes can be considered for refactoring&lt;br /&gt;
|-&lt;br /&gt;
| ||A flog report has been explained and shown here http://www.ruby-forum.com/topic/131931&lt;br /&gt;
|-&lt;br /&gt;
| ||&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= C# =&lt;br /&gt;
 &lt;br /&gt;
The list of frameworks that apply for .NET are applied for C#. A long list&lt;br /&gt;
of testing frameworks are available for C# which are NUnit, csUnit, Pex, dotunit,&lt;br /&gt;
VSNUnit, Nester[[http://csharp-source.net/open-source/testing-tools 13]].&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Nunit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''csUnit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''PEX'''&lt;br /&gt;
|-&lt;br /&gt;
| Description||NUnit has been ported from JUnit and has been written completely to take adavntage of the .NET languages.   It is a free open source unit testing tool for all the test-driven development .NET languages including C#.||The major advancements with NUnit are parameterized tests which provides a concise method to express a set of examples that can used to run individual test cases. It has been inspired from JUnit and can be used as an add-in along with the NUnit&lt;br /&gt;
&lt;br /&gt;
||It is a tool to generate efficient unit tests with a high code coverage and are converted to C# automatically. It determines the relevant test inputs for the code hunting for boundary conditions, exceptions and assertion failures. Pex enables Parameterized Unit Testing, an extension of Unit Testing that reduces test maintenance costs. &lt;br /&gt;
|-&lt;br /&gt;
| Examples||http://www.nunit.org/blogs/||http://www.csunit.org/tutorials/tutorial7/||http://research.microsoft.com/en-us/um/redmond/projects/pex/wiki/The%20Hello%20World%20of%20Pex.html&lt;br /&gt;
|-&lt;br /&gt;
| Used as ||Testing framework, GUI and console tool||Testing Framework ,Console tool and VS.NET Add In||It supports NUnit, MbUnit and xUnit.net.Extensions for these test frameworks can be downloaded from the Pex Extensions Project[[http://research.microsoft.com/en-us/um/redmond/projects/pex/wiki/reference%20manual.html 14]].&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=APPENDIX=&lt;br /&gt;
&lt;br /&gt;
'''1''' '''JUnit''' - JUnit is a unit testing framework for the Java programming language. JUnit has been important in the development of test-driven development, and comprises a family of unit testing frameworks collectively known as xUnit that originated with SUnit. (For more information refer to http://www.junit.org,http://en.wikipedia.org/wiki/Junit)&lt;br /&gt;
&lt;br /&gt;
'''2''' '''XUnit''' - Various code-driven testing frameworks have come to be known collectively as xUnit. These frameworks allow testing of different elements (units) of software, such as functions and classes. (For more information refer to http://en.wikipedia.org/wiki/XUnit)&lt;br /&gt;
&lt;br /&gt;
'''3''' '''unit testing''' - unit testing is a software verification and validation method in which a programmer tests if individual units of source code are fit for use, where a unit is the smallest testable part of an application. For more information refer http://en.wikipedia.org/wiki/Unit_testing&lt;br /&gt;
&lt;br /&gt;
'''4''' '''integration testing''' - is the activity of software testing in which individual software modules are combined and tested as a group. It occurs after unit testing. For more information refer http://en.wikipedia.org/wiki/Integration_testing&lt;br /&gt;
&lt;br /&gt;
'''5''' '''BeforeClass''' - Refer to http://junit.sourceforge.net/javadoc_40/org/junit/BeforeClass.html&lt;br /&gt;
&lt;br /&gt;
'''6''' '''parameterized testing''' - . A parameterized unit test is simply a method that takes parameters, calls the code under test, and states assertions.&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[1]  http://testng.org/doc/documentation-main.html&lt;br /&gt;
&lt;br /&gt;
[2]  http://jakarta.apache.org/cactus/index.html&lt;br /&gt;
&lt;br /&gt;
[3]  http://junit.sourceforge.net/doc/cookbook/cookbook.htm&lt;br /&gt;
&lt;br /&gt;
[4]  http://www.ibm.com/developerworks/java/library/j-cq08296&lt;br /&gt;
&lt;br /&gt;
[5]  http://www.opensourcetesting.org/unit_java.php&lt;br /&gt;
&lt;br /&gt;
[6]  http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle&lt;br /&gt;
&lt;br /&gt;
[7] http://en.wikipedia.org/wiki/Doctest&lt;br /&gt;
&lt;br /&gt;
[8] http://en.wikipedia.org/wiki/Unit_testing&lt;br /&gt;
&lt;br /&gt;
[9] http://www.elctech.com/tutorials/rspec-tutorial&lt;br /&gt;
&lt;br /&gt;
[10] http://www.rubyinside.com/cucumber-the-latest-in-ruby-testing-1342.html&lt;br /&gt;
&lt;br /&gt;
[11] http://www.ruby-forum.com/topic/144083&lt;br /&gt;
&lt;br /&gt;
[12] http://www.brynary.com/2007/9/13/scourging-your-ruby-code-with-flog&lt;br /&gt;
&lt;br /&gt;
[13] http://csharp-source.net/open-source/testing-tools&lt;br /&gt;
&lt;br /&gt;
[14] http://research.microsoft.com/en-us/um/redmond/projects/pex/wiki/reference%20manual.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b12_AV&amp;diff=22406</id>
		<title>CSC/ECE 517 Fall 2009/wiki1b12 AV</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b12_AV&amp;diff=22406"/>
		<updated>2009-09-29T03:19:50Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;XUnit in general, is only one kind of testing framework for object oriented languages. This page talks about the major testing frameworks available for the major object oriented languages such as Java, C++, C#,Python, Ruby and C#. Comparisons have been made wherever possible between the major frameworks available in each language. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Java Testing Frameworks =&lt;br /&gt;
&lt;br /&gt;
Plenty of testing framework exist for Java. JUnit has been the de facto standard for unit testing. However, other frameworks such as TestNG, JTIGER have been built to address various faults and deficiencies with JUnit.  Our primary objective is to compare the various testing frameworks that exist for object oriented languages based on the primary purpose of the framework, features, the platforms on which they operate, etc and thus help in picking up the best testing framework that fits in a particular suitable environment.&lt;br /&gt;
This article DOES NOT introduce JUnit or XUnit. For information on JUnit and XUnit, please refer to the http://www.junit.org or [[http://en.wikipedia.org/wiki/Junit '''APPENDIX 1''']] and [[http://en.wikipedia.org/wiki/XUnit '''APPENDIX 2''']] &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== TestNG Framework ==&lt;br /&gt;
&lt;br /&gt;
TestNG is a testing framework which can help to meet a broad range of testing such as unit testing, integration testing, functional testing, end-to -end testing. (For definition and more information on the different kinds of testing, refer to [[http://en.wikipedia.org/wiki/Unit_testing ''' APPENDIX 3''']] and [[http://en.wikipedia.org/wiki/Integration_testing ''' APPENDIX 4''']]&lt;br /&gt;
&lt;br /&gt;
To write a TestNG test, we need to:&lt;br /&gt;
Write the business logic of the test, and insert the TestNG annotations in them.&lt;br /&gt;
Add the information about our test (such as the class name, the groups we wish to run, etc) in a testing.xml file or in build.xml. &lt;br /&gt;
Run the test.&lt;br /&gt;
TestNG supports data driven testing.(Data-driven testing is a methodology used in Test automation where test scripts are executed and verified based on the data values stored in one or more central data sources or databases. For a detailed description on data driven testing click here: http://en.wikipedia.org/wiki/Data-driven_testing  )&lt;br /&gt;
&lt;br /&gt;
TestNG is invoked in several different ways: &lt;br /&gt;
With a testing.xml file&lt;br /&gt;
ANT&lt;br /&gt;
Command line&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is possible to group the test methods of TestNG.  We can declare methods that belong to these groups and specify groups that contain other groups. It is very flexible as it can help in choosing one set of regular expression and excluding the other sets. This splits the various test groups and there is no need to recompile again if we want to run two different tests back to back.&lt;br /&gt;
&lt;br /&gt;
Requirements:&lt;br /&gt;
JDK 1.4, 1.5&lt;br /&gt;
Invoked in many environments such as command line, ant, ECLIPSE, IDEA, MAVEN, etc&lt;br /&gt;
&lt;br /&gt;
The annotations available in TestNG can be found at:&lt;br /&gt;
http://testng.org/doc/documentation-main.html#annotations&lt;br /&gt;
&lt;br /&gt;
TestNG is inspired from JUnit and Nunit, with additional functionalities such as Flexible test configuration, support for data driven testing, etc.[[http://testng.org/doc/documentation-main.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Cactus ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Cactus is a test framework for testing server-side java code such as Servlets, EJB, etc. It extends J Unit.&lt;br /&gt;
Cactus implements an in-container strategy which means that tests are executed inside the container. &lt;br /&gt;
The Cactus testing unit can be viewed as a system that consists of the following components:&lt;br /&gt;
 &lt;br /&gt;
--Cactus Framework:  This provides the API to write Cactus tests. &lt;br /&gt;
&lt;br /&gt;
--Cactus Integration Modules: They are front ends and frameworks that provide easy ways of using the Cactus Framework. Eg: Eclipse plugin&lt;br /&gt;
&lt;br /&gt;
--Cactus Samples: They demonstrate how to write Cactus tests and how to use a few Integration Modules. [[http://jakarta.apache.org/cactus/index.html 2]]&lt;br /&gt;
&lt;br /&gt;
A useful testing framework provided by Cactus is  integration unit testing.  The tests written for this framework will exercise the interactions with the container. Cactus also provides other frameworks such as code logic unit testing, functional unit testing.&lt;br /&gt;
&lt;br /&gt;
Cactus was developed to fit only integration unit testing with the idea that it is much easier to have to write tests for a single framework than for several. It is believed that Cactus provides a middle ground that provides a high confidence that your code will run when deployed .[[http://jakarta.apache.org/cactus/index.html 2]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To know how it works, click here :&lt;br /&gt;
http://jakarta.apache.org/cactus/how_it_works.html&lt;br /&gt;
&lt;br /&gt;
== '''COMPARISON BETWEEN JUnit,TestNG and Cactus frameworks''' [[http://junit.sourceforge.net/doc/cookbook/cookbook.htm 3]] ==&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''JUnit4'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''TestNG'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Cactus'''&lt;br /&gt;
|-&lt;br /&gt;
| Supporting Type of Testing||Suitable more for Unit testing||Supports Unit testing,Functional testing, end-to-end testing, integration testing ||Primarily unit testing. Also have frameworks for code logic unit testing , functional logic unit testing&lt;br /&gt;
|-&lt;br /&gt;
| Conventions||Rigid  ||Flexible||Not as flexible as TestNG&lt;br /&gt;
|-&lt;br /&gt;
| Derived from JUnit||Yes, from the previous versions||Inspired from Junit,with  added functionalities ||Extends JUnit&lt;br /&gt;
|-&lt;br /&gt;
| Flexibility for large suites||Not flexible for large test suites, ||Flexible for running large test suites of code  and thus one test\'s failure shouldn\'t mean having to rerun a suite of thousands. || No, it is suitable for unit testing.&lt;br /&gt;
|-&lt;br /&gt;
| Suitable for ||Best for a single object||Best for a higher level testing||Best for server-side java code such as Servlets, EJB, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Works with||Command line, ANT,ECLIPSE||Command line,ANT, ECLIPSE, IDEA,MAVEN||ANT&lt;br /&gt;
|-&lt;br /&gt;
| ||||||&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== An example comparing JUNIT 4 and TestNG ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''JUnit 4  v/s TestNG'''&lt;br /&gt;
&lt;br /&gt;
(source: http://www.ibm.com/developerworks/java/library/j-cq08296/) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The frameworks differ is in their core design. JUnit has always been an effective unit-testing framework, meaning that it was built to facilitate testing single objects. TestNG, on the other hand, was built to address testing at higher levels, and consequently, has some features not available in JUnit&lt;br /&gt;
 &lt;br /&gt;
JUnit 4 makes clever use of annotations. JUnit no longer requires you to define a test as a method whose name starts with test, and we can now run fixtures just once as opposed to for each test.  However TestNG established itself as an annotations-based framework long before Junit 4. TestNG pioneered testing with annotations in Java programming, which made it a formidable alternative to JUnit. [[http://www.ibm.com/developerworks/java/library/j-cq08296 4]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Sample J Unit 4 code&lt;br /&gt;
&lt;br /&gt;
 package test.com.acme.dona.dep;&lt;br /&gt;
 import static org.junit.Assert.assertEquals;&lt;br /&gt;
 import static org.junit.Assert.assertNotNull;&lt;br /&gt;
 import org.junit.BeforeClass;&lt;br /&gt;
 import org.junit.Test;&lt;br /&gt;
 public class DependencyFinderTest {&lt;br /&gt;
 private static DependencyFinder finder;&lt;br /&gt;
 @BeforeClass&lt;br /&gt;
 public static void init() throws Exception {&lt;br /&gt;
  finder = new DependencyFinder();&lt;br /&gt;
 }&lt;br /&gt;
 @Test&lt;br /&gt;
 public void verifyDependencies() &lt;br /&gt;
  throws Exception {&lt;br /&gt;
   String targetClss = &lt;br /&gt;
     &amp;quot;test.com.acme.dona.dep.DependencyFind&amp;quot;;&lt;br /&gt;
 Filter[] filtr = new Filter[] { &lt;br /&gt;
      new RegexPackageFilter(&amp;quot;java|junit|org&amp;quot;)};&lt;br /&gt;
 Dependency[] deps = &lt;br /&gt;
      finder.findDependencies(targetClss, filtr);&lt;br /&gt;
 assertNotNull(&amp;quot;deps was null&amp;quot;, deps);&lt;br /&gt;
   assertEquals(&amp;quot;should be 5 large&amp;quot;, 5, deps.length);   &lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
 (source: http://www.ibm.com/developerworks/java/library/j-cq08296/)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Sample TestNG code&lt;br /&gt;
&lt;br /&gt;
 package test.com.acme.dona.dep;&lt;br /&gt;
 import static org.testng.Assert.assertEquals;&lt;br /&gt;
 import static org.testng.Assert.assertNotNull;&lt;br /&gt;
 import org.testng.annotations.BeforeClass;&lt;br /&gt;
 import org.testng.annotations.Configuration;&lt;br /&gt;
 import org.testng.annotations.Test;&lt;br /&gt;
 public class DependencyFinderTest {&lt;br /&gt;
 private DependencyFinder finder;&lt;br /&gt;
 @BeforeClass&lt;br /&gt;
 private void init(){&lt;br /&gt;
  this.finder = new DependencyFinder();&lt;br /&gt;
 }&lt;br /&gt;
 @Test&lt;br /&gt;
 public void verifyDependencies() &lt;br /&gt;
  throws Exception {&lt;br /&gt;
   String targetClss = &lt;br /&gt;
     &amp;quot;test.com.acme.dona.dep.DependencyFind&amp;quot;;&lt;br /&gt;
   Filter[] filtr = new Filter[] { &lt;br /&gt;
      new RegexPackageFilter(&amp;quot;java|junit|org&amp;quot;)};&lt;br /&gt;
   Dependency[] deps = &lt;br /&gt;
      finder.findDependencies(targetClss, filtr);&lt;br /&gt;
   assertNotNull(deps, &amp;quot;deps was null&amp;quot; );&lt;br /&gt;
   assertEquals(5, deps.length, &amp;quot;should be 5 large&amp;quot;);           &lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
 (source: http://www.ibm.com/developerworks/java/library/j-cq08296/)&lt;br /&gt;
&lt;br /&gt;
Both the codes may look a lot similar. However TestNG coding conventions are more flexible than JUnit 4.&lt;br /&gt;
&lt;br /&gt;
JUnit forces us to declare the @BeforeClass (See [[http://junit.sourceforge.net/javadoc_40/org/junit/BeforeClass.html '''APPENDIX 5''']] for more information)  method as static, which consequently requires us to also declare the fixture, finder, as static. We also have to declare the init() method as public. Looking at the TestNG code, you can find that such conventions aren't required. Its init() method is neither static nor public. &lt;br /&gt;
Flexibility has been one of the strong points of TestNG right from the start. JUnit works well for a unit of code, whereas TestNG is better suited for high-level testing. Its flexibility is especially useful with large test suites.[[http://www.ibm.com/developerworks/java/library/j-cq08296 4]]&lt;br /&gt;
&lt;br /&gt;
== Some other JAVA testing units [[http://www.opensourcetesting.org/unit_java.php 5]]  ==&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''JEasyTest'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''J2ME Unit Testing Toolkit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Jailer'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Mockrunner'''&lt;br /&gt;
|-&lt;br /&gt;
| Features||Generates coverage report Allows virtual mock object||Is a  Java 2 Micro Edition (J2ME) library containing a unit testing framework for J2ME||Does test data exporting.  JDBC agnostic  Generates DbUnit datasets, hierarchically structured XML, and topologically sorted SQL-DML.||A lightweight framework for unit testing applications in the J2EE environment.&lt;br /&gt;
|-&lt;br /&gt;
| Integrates with:||ECLIPSE 3.3||ANT ||Platform Independent||OS independent&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Testing frameworks for C++   =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When it comes to unit testing in Java, a unanimous choice would be JUnit. However for C++, there is no one clear winner.  CppUnit is the most widely used tool for C++ which is a part of the XUnit family.&lt;br /&gt;
&lt;br /&gt;
Following is a few basic factors to judge a good testing unit in C++ [[http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle 6]] &lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Features'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''CppUnit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''BOOST.test'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''CxxUnit'''&lt;br /&gt;
|-&lt;br /&gt;
| Minimal amount of work needed to add new tests ||No, and thus a major downfall.||Yes||Yes, very good.&lt;br /&gt;
|-&lt;br /&gt;
| Easy to modify and port ||Medium||Medium||Simplest&lt;br /&gt;
|-&lt;br /&gt;
| Supports setup/teardown steps ||Yes||||Best&lt;br /&gt;
|-&lt;br /&gt;
| Handles exceptions and crashes well.||Yes||Yes, above others||Great support.&lt;br /&gt;
|-&lt;br /&gt;
| Good assert functionality.||Pretty decent.||Yes||Best&lt;br /&gt;
|-&lt;br /&gt;
| Supports different outputs. ||Yes. Comes with IDE friendly output.||Probably, Not trivial to change.||Yes&lt;br /&gt;
|-&lt;br /&gt;
| Supports  suites||Yes.||Yes, but with a big catch. ||Yes&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CppUnit passes most of the above tests , except for the first point and thus needs a lot of code typing.&lt;br /&gt;
Boost.Test isn’t exclusively a unit-testing framework, and is not X Unit based.&lt;br /&gt;
&lt;br /&gt;
Out of the above three , cxxUnit turns out to be a favourite.&lt;br /&gt;
&lt;br /&gt;
It comes close to the requirements of an ideal framework by leveraging the power of an external scripting language. It provides some nifty advanced features and great assert functionality. It does require the use of a scripting language as part of the build process, so those uncomfortable with that requirement, might want to look at one of the other two frameworks.&lt;br /&gt;
&lt;br /&gt;
For work restricted to the PC,  where modifying the framework is not required Boost.Test could  be a very good choice.&lt;br /&gt;
CppUnit , which has come a long way in years is a solid, complete framework  The major drawbacks are the relative verbosity for adding new tests and fixtures. [[http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle 6]]&lt;br /&gt;
&lt;br /&gt;
= Python =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Doctest''': It is a simple, ingenuine technology that allows you to write a narrative in a document which can directly be executed as a test. It is included in Python as a module.&lt;br /&gt;
&lt;br /&gt;
Although doctest makes testing code readable for non-programmers ,the simplicity of a narrative test like doctest is accompanied by it’s own flaws .Some of the disadvantages of using doctest are&lt;br /&gt;
&lt;br /&gt;
•	These tests are difficult to handle in case of failures as they are more generic. Specific tests are narrower and better in communicating intent and ensuring coverage.&lt;br /&gt;
&lt;br /&gt;
•	The test code is executed in a special way thus making it difficult to reason about how it will be executed. It is also harder to program around the tests.&lt;br /&gt;
&lt;br /&gt;
•	It is actually difficult to get an outline of the tests at glance. There’s no tool that can give an overview of the unit tests in a doc test file [[http://en.wikipedia.org/wiki/Doctest 7]].&lt;br /&gt;
&lt;br /&gt;
An detailed information about doctest with thorough examples can be read at http://docs.python.org/library/doctest.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Unittest''': Unittest are more specific tests which are more functional in nature allowing it to be written for individual functions or the class as a whole. &lt;br /&gt;
&lt;br /&gt;
The fact that Unittest is based on jUnit makes people with the xUnit familiarity pick it up really quick hence it is more Java based than python .It has been introduced in the Python’s library since version 2.1 &lt;br /&gt;
&lt;br /&gt;
The disadvantages of using the unit test are &lt;br /&gt;
&lt;br /&gt;
•	The tests have a different look and feel with respect to the code under test&lt;br /&gt;
&lt;br /&gt;
•	The assertions used in the text use custom syntax which makes it difficult&lt;br /&gt;
&lt;br /&gt;
•	The test code is difficult to understand compared to the Doctest and the strong basis on jUnit makes it difficult for the pure Python coders [[http://en.wikipedia.org/wiki/Unit_testing 8]]&lt;br /&gt;
&lt;br /&gt;
A detailed information about doctest with thorough examples can be read at http://docs.python.org/library/unittest.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Doctest vs Unittest'''&lt;br /&gt;
&lt;br /&gt;
Here we compare simple features of both the tests thus giving us an idea of which one to use based on the requirement&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''doctest'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''unittest'''&lt;br /&gt;
|-&lt;br /&gt;
| '''Simplicity'''||Best suited for novice programmers||A little complex to use specially if unaware of Junit&lt;br /&gt;
|-&lt;br /&gt;
| '''Documentation'''||Better Narratives||Tests have little or no comments&lt;br /&gt;
|-&lt;br /&gt;
| '''Comprehensive testing'''||Doctests get clutterd for comprehensive tests and thus less readable||Best suited for comprehensive tests&lt;br /&gt;
|-&lt;br /&gt;
| '''Flexibility and Control'''||Less flexible||More flexible&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Ruby =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The basic testing framework for RUBY is xUnit . There are some frameworks which have evolved over the years which include RSpec, Trantula, Flog, RunCodeRun, Cucumber etc. We’ll talk about each of them in brief&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Testing Framework'''&lt;br /&gt;
| style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Description'''&lt;br /&gt;
|-&lt;br /&gt;
| '''Rspec[[http://www.elctech.com/tutorials/rspec-tutorial 9]]'''||It is Behavior Driven Development whose basic features are&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Behavior counts first, testing follows&lt;br /&gt;
|-&lt;br /&gt;
| ||·         It focuses more on business values&lt;br /&gt;
|-&lt;br /&gt;
| ||·         It’s more about getting the words right rather than just writing the test first&lt;br /&gt;
|-&lt;br /&gt;
| ||Advantages:&lt;br /&gt;
|-&lt;br /&gt;
| ||·         These are extremely easy to read and makes sense to a non-programmer&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Rspec lets you unit test while also providing mocking and stubbing support&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Rspec can help with the coverage tests using Rcov&lt;br /&gt;
|-&lt;br /&gt;
| ||·         One can also perform integration test using Rspec &lt;br /&gt;
|-&lt;br /&gt;
| ||Disadvantages:&lt;br /&gt;
|-&lt;br /&gt;
| ||·         It involves a lot of behind the scene metaprogramming which makes the tests very difficult to understand&lt;br /&gt;
|-&lt;br /&gt;
| ||A simple Rspec example can be read at http://rspec.info/&lt;br /&gt;
|-&lt;br /&gt;
| '''Cucumber[[http://www.rubyinside.com/cucumber-the-latest-in-ruby-testing-1342.html 10]]'''||Cucumber, the latest addition to the Rspec family allows one to execute documentation written in plain text(known as ‘stories’)&lt;br /&gt;
|-&lt;br /&gt;
| ||A very good example of writing a test in cucumber can be read at http://cukes.info/&lt;br /&gt;
|-&lt;br /&gt;
| ||&lt;br /&gt;
|-&lt;br /&gt;
| '''Tarantula[[http://www.ruby-forum.com/topic/144083 11]]'''||Tarantula is a Rail’s plugin that produces a detailed report describing the URL’s that it has crawled across and the responses that it received from each one of them.&lt;br /&gt;
|-&lt;br /&gt;
| ||Tarantula\'s functionality somewhat overlaps with the on site testing, particularly if you are practicing test-driven development (TDD). Tarantula runs against your actual Web site thereby helping you to identify the problems associated with your production server, user-generated data, and HTML compliance.&lt;br /&gt;
&lt;br /&gt;
A well explained example can be seen at http://www.railslodge.com/plugins/959-tarantula&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| '''Flog[[http://www.brynary.com/2007/9/13/scourging-your-ruby-code-with-flog 12]]'''||Flog is a tool which gives you a profile of your code’s complexity. It can given the complexity pertaining to each method in your code. One can also set threshold for each method using flog &lt;br /&gt;
|-&lt;br /&gt;
| ||The complexity of a code can be important to &lt;br /&gt;
|-&lt;br /&gt;
| ||·         Find the bugs as they are highly probable in complex code areas&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Complex codes can be considered for refactoring&lt;br /&gt;
|-&lt;br /&gt;
| ||A flog report has been explained and shown here http://www.ruby-forum.com/topic/131931&lt;br /&gt;
|-&lt;br /&gt;
| ||&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= C# =&lt;br /&gt;
 &lt;br /&gt;
The list of frameworks that apply for .NET are applied for C#. A long list&lt;br /&gt;
of testing frameworks are available for C# which are NUnit, csUnit, Pex, dotunit,&lt;br /&gt;
VSNUnit, Nester[[http://csharp-source.net/open-source/testing-tools 13]].&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Nunit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''csUnit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''PEX'''&lt;br /&gt;
|-&lt;br /&gt;
| Description||NUnit has been ported from JUnit and has been written completely to take adavntage of the .NET languages.   It is a free open source unit testing tool for all the test-driven development .NET languages including C#.||The major advancements with NUnit are parameterized tests which provides a concise method to express a set of examples that can used to run individual test cases. It has been inspired from JUnit and can be used as an add-in along with the NUnit&lt;br /&gt;
&lt;br /&gt;
||It is a tool to generate efficient unit tests with a high code coverage and are converted to C# automatically. It determines the relevant test inputs for the code hunting for boundary conditions, exceptions and assertion failures. Pex enables Parameterized Unit Testing, an extension of Unit Testing that reduces test maintenance costs. &lt;br /&gt;
|-&lt;br /&gt;
| Examples||http://www.nunit.org/blogs/||http://www.csunit.org/tutorials/tutorial7/||http://research.microsoft.com/en-us/um/redmond/projects/pex/wiki/The%20Hello%20World%20of%20Pex.html&lt;br /&gt;
|-&lt;br /&gt;
| Used as ||Testing framework, GUI and console tool||Testing Framework ,Console tool and VS.NET Add In||It supports NUnit, MbUnit and xUnit.net.Extensions for these test frameworks can be downloaded from the Pex Extensions Project.&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=APPENDIX=&lt;br /&gt;
&lt;br /&gt;
'''1''' '''JUnit''' - JUnit is a unit testing framework for the Java programming language. JUnit has been important in the development of test-driven development, and comprises a family of unit testing frameworks collectively known as xUnit that originated with SUnit. (For more information refer to http://www.junit.org,http://en.wikipedia.org/wiki/Junit)&lt;br /&gt;
&lt;br /&gt;
'''2''' '''XUnit''' - Various code-driven testing frameworks have come to be known collectively as xUnit. These frameworks allow testing of different elements (units) of software, such as functions and classes. (For more information refer to http://en.wikipedia.org/wiki/XUnit)&lt;br /&gt;
&lt;br /&gt;
'''3''' '''unit testing''' - unit testing is a software verification and validation method in which a programmer tests if individual units of source code are fit for use, where a unit is the smallest testable part of an application. For more information refer http://en.wikipedia.org/wiki/Unit_testing&lt;br /&gt;
&lt;br /&gt;
'''4''' '''integration testing''' - is the activity of software testing in which individual software modules are combined and tested as a group. It occurs after unit testing. For more information refer http://en.wikipedia.org/wiki/Integration_testing&lt;br /&gt;
&lt;br /&gt;
'''5''' '''BeforeClass''' - Refer to http://junit.sourceforge.net/javadoc_40/org/junit/BeforeClass.html&lt;br /&gt;
&lt;br /&gt;
'''6''' '''parameterized testing''' - . A parameterized unit test is simply a method that takes parameters, calls the code under test, and states assertions.&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[1]  http://testng.org/doc/documentation-main.html&lt;br /&gt;
&lt;br /&gt;
[2]  http://jakarta.apache.org/cactus/index.html&lt;br /&gt;
&lt;br /&gt;
[3]  http://junit.sourceforge.net/doc/cookbook/cookbook.htm&lt;br /&gt;
&lt;br /&gt;
[4]  http://www.ibm.com/developerworks/java/library/j-cq08296&lt;br /&gt;
&lt;br /&gt;
[5]  http://www.opensourcetesting.org/unit_java.php&lt;br /&gt;
&lt;br /&gt;
[6]  http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle&lt;br /&gt;
&lt;br /&gt;
[7] http://en.wikipedia.org/wiki/Doctest&lt;br /&gt;
&lt;br /&gt;
[8] http://en.wikipedia.org/wiki/Unit_testing&lt;br /&gt;
&lt;br /&gt;
[9] http://www.elctech.com/tutorials/rspec-tutorial&lt;br /&gt;
&lt;br /&gt;
[10] http://www.rubyinside.com/cucumber-the-latest-in-ruby-testing-1342.html&lt;br /&gt;
&lt;br /&gt;
[11] http://www.ruby-forum.com/topic/144083&lt;br /&gt;
&lt;br /&gt;
[12] http://www.brynary.com/2007/9/13/scourging-your-ruby-code-with-flog&lt;br /&gt;
&lt;br /&gt;
[13] http://csharp-source.net/open-source/testing-tools&lt;br /&gt;
&lt;br /&gt;
[14] http://research.microsoft.com/en-us/um/redmond/projects/pex/wiki/reference%20manual.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b12_AV&amp;diff=22405</id>
		<title>CSC/ECE 517 Fall 2009/wiki1b12 AV</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b12_AV&amp;diff=22405"/>
		<updated>2009-09-29T03:18:10Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* APPENDIX */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;XUnit in general, is only one kind of testing framework for object oriented languages. This page talks about the major testing frameworks available for the major object oriented languages such as Java, C++, C#,Python, Ruby and C#. Comparisons have been made wherever possible between the major frameworks available in each language. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Java Testing Frameworks =&lt;br /&gt;
&lt;br /&gt;
Plenty of testing framework exist for Java. JUnit has been the de facto standard for unit testing. However, other frameworks such as TestNG, JTIGER have been built to address various faults and deficiencies with JUnit.  Our primary objective is to compare the various testing frameworks that exist for object oriented languages based on the primary purpose of the framework, features, the platforms on which they operate, etc and thus help in picking up the best testing framework that fits in a particular suitable environment.&lt;br /&gt;
This article DOES NOT introduce JUnit or XUnit. For information on JUnit and XUnit, please refer to the http://www.junit.org or [[http://en.wikipedia.org/wiki/Junit '''APPENDIX 1''']] and [[http://en.wikipedia.org/wiki/XUnit '''APPENDIX 2''']] &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== TestNG Framework ==&lt;br /&gt;
&lt;br /&gt;
TestNG is a testing framework which can help to meet a broad range of testing such as unit testing, integration testing, functional testing, end-to -end testing. (For definition and more information on the different kinds of testing, refer to [[http://en.wikipedia.org/wiki/Unit_testing ''' APPENDIX 3''']] and [[http://en.wikipedia.org/wiki/Integration_testing ''' APPENDIX 4''']]&lt;br /&gt;
&lt;br /&gt;
To write a TestNG test, we need to:&lt;br /&gt;
Write the business logic of the test, and insert the TestNG annotations in them.&lt;br /&gt;
Add the information about our test (such as the class name, the groups we wish to run, etc) in a testing.xml file or in build.xml. &lt;br /&gt;
Run the test.&lt;br /&gt;
TestNG supports data driven testing.(Data-driven testing is a methodology used in Test automation where test scripts are executed and verified based on the data values stored in one or more central data sources or databases. For a detailed description on data driven testing click here: http://en.wikipedia.org/wiki/Data-driven_testing  )&lt;br /&gt;
&lt;br /&gt;
TestNG is invoked in several different ways: &lt;br /&gt;
With a testing.xml file&lt;br /&gt;
ANT&lt;br /&gt;
Command line&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is possible to group the test methods of TestNG.  We can declare methods that belong to these groups and specify groups that contain other groups. It is very flexible as it can help in choosing one set of regular expression and excluding the other sets. This splits the various test groups and there is no need to recompile again if we want to run two different tests back to back.&lt;br /&gt;
&lt;br /&gt;
Requirements:&lt;br /&gt;
JDK 1.4, 1.5&lt;br /&gt;
Invoked in many environments such as command line, ant, ECLIPSE, IDEA, MAVEN, etc&lt;br /&gt;
&lt;br /&gt;
The annotations available in TestNG can be found at:&lt;br /&gt;
http://testng.org/doc/documentation-main.html#annotations&lt;br /&gt;
&lt;br /&gt;
TestNG is inspired from JUnit and Nunit, with additional functionalities such as Flexible test configuration, support for data driven testing, etc.[[http://testng.org/doc/documentation-main.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Cactus ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Cactus is a test framework for testing server-side java code such as Servlets, EJB, etc. It extends J Unit.&lt;br /&gt;
Cactus implements an in-container strategy which means that tests are executed inside the container. &lt;br /&gt;
The Cactus testing unit can be viewed as a system that consists of the following components:&lt;br /&gt;
 &lt;br /&gt;
--Cactus Framework:  This provides the API to write Cactus tests. &lt;br /&gt;
&lt;br /&gt;
--Cactus Integration Modules: They are front ends and frameworks that provide easy ways of using the Cactus Framework. Eg: Eclipse plugin&lt;br /&gt;
&lt;br /&gt;
--Cactus Samples: They demonstrate how to write Cactus tests and how to use a few Integration Modules. [[http://jakarta.apache.org/cactus/index.html 2]]&lt;br /&gt;
&lt;br /&gt;
A useful testing framework provided by Cactus is  integration unit testing.  The tests written for this framework will exercise the interactions with the container. Cactus also provides other frameworks such as code logic unit testing, functional unit testing.&lt;br /&gt;
&lt;br /&gt;
Cactus was developed to fit only integration unit testing with the idea that it is much easier to have to write tests for a single framework than for several. It is believed that Cactus provides a middle ground that provides a high confidence that your code will run when deployed .[[http://jakarta.apache.org/cactus/index.html 2]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To know how it works, click here :&lt;br /&gt;
http://jakarta.apache.org/cactus/how_it_works.html&lt;br /&gt;
&lt;br /&gt;
== '''COMPARISON BETWEEN JUnit,TestNG and Cactus frameworks''' [[http://junit.sourceforge.net/doc/cookbook/cookbook.htm 3]] ==&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''JUnit4'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''TestNG'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Cactus'''&lt;br /&gt;
|-&lt;br /&gt;
| Supporting Type of Testing||Suitable more for Unit testing||Supports Unit testing,Functional testing, end-to-end testing, integration testing ||Primarily unit testing. Also have frameworks for code logic unit testing , functional logic unit testing&lt;br /&gt;
|-&lt;br /&gt;
| Conventions||Rigid  ||Flexible||Not as flexible as TestNG&lt;br /&gt;
|-&lt;br /&gt;
| Derived from JUnit||Yes, from the previous versions||Inspired from Junit,with  added functionalities ||Extends JUnit&lt;br /&gt;
|-&lt;br /&gt;
| Flexibility for large suites||Not flexible for large test suites, ||Flexible for running large test suites of code  and thus one test\'s failure shouldn\'t mean having to rerun a suite of thousands. || No, it is suitable for unit testing.&lt;br /&gt;
|-&lt;br /&gt;
| Suitable for ||Best for a single object||Best for a higher level testing||Best for server-side java code such as Servlets, EJB, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Works with||Command line, ANT,ECLIPSE||Command line,ANT, ECLIPSE, IDEA,MAVEN||ANT&lt;br /&gt;
|-&lt;br /&gt;
| ||||||&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== An example comparing JUNIT 4 and TestNG ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''JUnit 4  v/s TestNG'''&lt;br /&gt;
&lt;br /&gt;
(source: http://www.ibm.com/developerworks/java/library/j-cq08296/) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The frameworks differ is in their core design. JUnit has always been an effective unit-testing framework, meaning that it was built to facilitate testing single objects. TestNG, on the other hand, was built to address testing at higher levels, and consequently, has some features not available in JUnit&lt;br /&gt;
 &lt;br /&gt;
JUnit 4 makes clever use of annotations. JUnit no longer requires you to define a test as a method whose name starts with test, and we can now run fixtures just once as opposed to for each test.  However TestNG established itself as an annotations-based framework long before Junit 4. TestNG pioneered testing with annotations in Java programming, which made it a formidable alternative to JUnit. [[http://www.ibm.com/developerworks/java/library/j-cq08296 4]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Sample J Unit 4 code&lt;br /&gt;
&lt;br /&gt;
 package test.com.acme.dona.dep;&lt;br /&gt;
 import static org.junit.Assert.assertEquals;&lt;br /&gt;
 import static org.junit.Assert.assertNotNull;&lt;br /&gt;
 import org.junit.BeforeClass;&lt;br /&gt;
 import org.junit.Test;&lt;br /&gt;
 public class DependencyFinderTest {&lt;br /&gt;
 private static DependencyFinder finder;&lt;br /&gt;
 @BeforeClass&lt;br /&gt;
 public static void init() throws Exception {&lt;br /&gt;
  finder = new DependencyFinder();&lt;br /&gt;
 }&lt;br /&gt;
 @Test&lt;br /&gt;
 public void verifyDependencies() &lt;br /&gt;
  throws Exception {&lt;br /&gt;
   String targetClss = &lt;br /&gt;
     &amp;quot;test.com.acme.dona.dep.DependencyFind&amp;quot;;&lt;br /&gt;
 Filter[] filtr = new Filter[] { &lt;br /&gt;
      new RegexPackageFilter(&amp;quot;java|junit|org&amp;quot;)};&lt;br /&gt;
 Dependency[] deps = &lt;br /&gt;
      finder.findDependencies(targetClss, filtr);&lt;br /&gt;
 assertNotNull(&amp;quot;deps was null&amp;quot;, deps);&lt;br /&gt;
   assertEquals(&amp;quot;should be 5 large&amp;quot;, 5, deps.length);   &lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
 (source: http://www.ibm.com/developerworks/java/library/j-cq08296/)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Sample TestNG code&lt;br /&gt;
&lt;br /&gt;
 package test.com.acme.dona.dep;&lt;br /&gt;
 import static org.testng.Assert.assertEquals;&lt;br /&gt;
 import static org.testng.Assert.assertNotNull;&lt;br /&gt;
 import org.testng.annotations.BeforeClass;&lt;br /&gt;
 import org.testng.annotations.Configuration;&lt;br /&gt;
 import org.testng.annotations.Test;&lt;br /&gt;
 public class DependencyFinderTest {&lt;br /&gt;
 private DependencyFinder finder;&lt;br /&gt;
 @BeforeClass&lt;br /&gt;
 private void init(){&lt;br /&gt;
  this.finder = new DependencyFinder();&lt;br /&gt;
 }&lt;br /&gt;
 @Test&lt;br /&gt;
 public void verifyDependencies() &lt;br /&gt;
  throws Exception {&lt;br /&gt;
   String targetClss = &lt;br /&gt;
     &amp;quot;test.com.acme.dona.dep.DependencyFind&amp;quot;;&lt;br /&gt;
   Filter[] filtr = new Filter[] { &lt;br /&gt;
      new RegexPackageFilter(&amp;quot;java|junit|org&amp;quot;)};&lt;br /&gt;
   Dependency[] deps = &lt;br /&gt;
      finder.findDependencies(targetClss, filtr);&lt;br /&gt;
   assertNotNull(deps, &amp;quot;deps was null&amp;quot; );&lt;br /&gt;
   assertEquals(5, deps.length, &amp;quot;should be 5 large&amp;quot;);           &lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
 (source: http://www.ibm.com/developerworks/java/library/j-cq08296/)&lt;br /&gt;
&lt;br /&gt;
Both the codes may look a lot similar. However TestNG coding conventions are more flexible than JUnit 4.&lt;br /&gt;
&lt;br /&gt;
JUnit forces us to declare the @BeforeClass (See [[http://junit.sourceforge.net/javadoc_40/org/junit/BeforeClass.html '''APPENDIX 5''']] for more information)  method as static, which consequently requires us to also declare the fixture, finder, as static. We also have to declare the init() method as public. Looking at the TestNG code, you can find that such conventions aren't required. Its init() method is neither static nor public. &lt;br /&gt;
Flexibility has been one of the strong points of TestNG right from the start. JUnit works well for a unit of code, whereas TestNG is better suited for high-level testing. Its flexibility is especially useful with large test suites.[[http://www.ibm.com/developerworks/java/library/j-cq08296 4]]&lt;br /&gt;
&lt;br /&gt;
== Some other JAVA testing units [[http://www.opensourcetesting.org/unit_java.php 5]]  ==&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''JEasyTest'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''J2ME Unit Testing Toolkit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Jailer'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Mockrunner'''&lt;br /&gt;
|-&lt;br /&gt;
| Features||Generates coverage report Allows virtual mock object||Is a  Java 2 Micro Edition (J2ME) library containing a unit testing framework for J2ME||Does test data exporting.  JDBC agnostic  Generates DbUnit datasets, hierarchically structured XML, and topologically sorted SQL-DML.||A lightweight framework for unit testing applications in the J2EE environment.&lt;br /&gt;
|-&lt;br /&gt;
| Integrates with:||ECLIPSE 3.3||ANT ||Platform Independent||OS independent&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Testing frameworks for C++   =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When it comes to unit testing in Java, a unanimous choice would be JUnit. However for C++, there is no one clear winner.  CppUnit is the most widely used tool for C++ which is a part of the XUnit family.&lt;br /&gt;
&lt;br /&gt;
Following is a few basic factors to judge a good testing unit in C++ [[http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle 6]] &lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Features'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''CppUnit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''BOOST.test'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''CxxUnit'''&lt;br /&gt;
|-&lt;br /&gt;
| Minimal amount of work needed to add new tests ||No, and thus a major downfall.||Yes||Yes, very good.&lt;br /&gt;
|-&lt;br /&gt;
| Easy to modify and port ||Medium||Medium||Simplest&lt;br /&gt;
|-&lt;br /&gt;
| Supports setup/teardown steps ||Yes||||Best&lt;br /&gt;
|-&lt;br /&gt;
| Handles exceptions and crashes well.||Yes||Yes, above others||Great support.&lt;br /&gt;
|-&lt;br /&gt;
| Good assert functionality.||Pretty decent.||Yes||Best&lt;br /&gt;
|-&lt;br /&gt;
| Supports different outputs. ||Yes. Comes with IDE friendly output.||Probably, Not trivial to change.||Yes&lt;br /&gt;
|-&lt;br /&gt;
| Supports  suites||Yes.||Yes, but with a big catch. ||Yes&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CppUnit passes most of the above tests , except for the first point and thus needs a lot of code typing.&lt;br /&gt;
Boost.Test isn’t exclusively a unit-testing framework, and is not X Unit based.&lt;br /&gt;
&lt;br /&gt;
Out of the above three , cxxUnit turns out to be a favourite.&lt;br /&gt;
&lt;br /&gt;
It comes close to the requirements of an ideal framework by leveraging the power of an external scripting language. It provides some nifty advanced features and great assert functionality. It does require the use of a scripting language as part of the build process, so those uncomfortable with that requirement, might want to look at one of the other two frameworks.&lt;br /&gt;
&lt;br /&gt;
For work restricted to the PC,  where modifying the framework is not required Boost.Test could  be a very good choice.&lt;br /&gt;
CppUnit , which has come a long way in years is a solid, complete framework  The major drawbacks are the relative verbosity for adding new tests and fixtures. [[http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle 6]]&lt;br /&gt;
&lt;br /&gt;
= Python =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Doctest''': It is a simple, ingenuine technology that allows you to write a narrative in a document which can directly be executed as a test. It is included in Python as a module.&lt;br /&gt;
&lt;br /&gt;
Although doctest makes testing code readable for non-programmers ,the simplicity of a narrative test like doctest is accompanied by it’s own flaws .Some of the disadvantages of using doctest are&lt;br /&gt;
&lt;br /&gt;
•	These tests are difficult to handle in case of failures as they are more generic. Specific tests are narrower and better in communicating intent and ensuring coverage.&lt;br /&gt;
&lt;br /&gt;
•	The test code is executed in a special way thus making it difficult to reason about how it will be executed. It is also harder to program around the tests.&lt;br /&gt;
&lt;br /&gt;
•	It is actually difficult to get an outline of the tests at glance. There’s no tool that can give an overview of the unit tests in a doc test file [[http://en.wikipedia.org/wiki/Doctest 7]].&lt;br /&gt;
&lt;br /&gt;
An detailed information about doctest with thorough examples can be read at http://docs.python.org/library/doctest.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Unittest''': Unittest are more specific tests which are more functional in nature allowing it to be written for individual functions or the class as a whole. &lt;br /&gt;
&lt;br /&gt;
The fact that Unittest is based on jUnit makes people with the xUnit familiarity pick it up really quick hence it is more Java based than python .It has been introduced in the Python’s library since version 2.1 &lt;br /&gt;
&lt;br /&gt;
The disadvantages of using the unit test are &lt;br /&gt;
&lt;br /&gt;
•	The tests have a different look and feel with respect to the code under test&lt;br /&gt;
&lt;br /&gt;
•	The assertions used in the text use custom syntax which makes it difficult&lt;br /&gt;
&lt;br /&gt;
•	The test code is difficult to understand compared to the Doctest and the strong basis on jUnit makes it difficult for the pure Python coders [[http://en.wikipedia.org/wiki/Unit_testing 8]]&lt;br /&gt;
&lt;br /&gt;
A detailed information about doctest with thorough examples can be read at http://docs.python.org/library/unittest.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Doctest vs Unittest'''&lt;br /&gt;
&lt;br /&gt;
Here we compare simple features of both the tests thus giving us an idea of which one to use based on the requirement&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''doctest'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''unittest'''&lt;br /&gt;
|-&lt;br /&gt;
| '''Simplicity'''||Best suited for novice programmers||A little complex to use specially if unaware of Junit&lt;br /&gt;
|-&lt;br /&gt;
| '''Documentation'''||Better Narratives||Tests have little or no comments&lt;br /&gt;
|-&lt;br /&gt;
| '''Comprehensive testing'''||Doctests get clutterd for comprehensive tests and thus less readable||Best suited for comprehensive tests&lt;br /&gt;
|-&lt;br /&gt;
| '''Flexibility and Control'''||Less flexible||More flexible&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Ruby =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The basic testing framework for RUBY is xUnit . There are some frameworks which have evolved over the years which include RSpec, Trantula, Flog, RunCodeRun, Cucumber etc. We’ll talk about each of them in brief&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Testing Framework'''&lt;br /&gt;
| style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Description'''&lt;br /&gt;
|-&lt;br /&gt;
| '''Rspec[[http://www.elctech.com/tutorials/rspec-tutorial 9]]'''||It is Behavior Driven Development whose basic features are&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Behavior counts first, testing follows&lt;br /&gt;
|-&lt;br /&gt;
| ||·         It focuses more on business values&lt;br /&gt;
|-&lt;br /&gt;
| ||·         It’s more about getting the words right rather than just writing the test first&lt;br /&gt;
|-&lt;br /&gt;
| ||Advantages:&lt;br /&gt;
|-&lt;br /&gt;
| ||·         These are extremely easy to read and makes sense to a non-programmer&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Rspec lets you unit test while also providing mocking and stubbing support&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Rspec can help with the coverage tests using Rcov&lt;br /&gt;
|-&lt;br /&gt;
| ||·         One can also perform integration test using Rspec &lt;br /&gt;
|-&lt;br /&gt;
| ||Disadvantages:&lt;br /&gt;
|-&lt;br /&gt;
| ||·         It involves a lot of behind the scene metaprogramming which makes the tests very difficult to understand&lt;br /&gt;
|-&lt;br /&gt;
| ||A simple Rspec example can be read at http://rspec.info/&lt;br /&gt;
|-&lt;br /&gt;
| '''Cucumber[[http://www.rubyinside.com/cucumber-the-latest-in-ruby-testing-1342.html 10]]'''||Cucumber, the latest addition to the Rspec family allows one to execute documentation written in plain text(known as ‘stories’)&lt;br /&gt;
|-&lt;br /&gt;
| ||A very good example of writing a test in cucumber can be read at http://cukes.info/&lt;br /&gt;
|-&lt;br /&gt;
| ||&lt;br /&gt;
|-&lt;br /&gt;
| '''Tarantula[[http://www.ruby-forum.com/topic/144083 11]]'''||Tarantula is a Rail’s plugin that produces a detailed report describing the URL’s that it has crawled across and the responses that it received from each one of them.&lt;br /&gt;
|-&lt;br /&gt;
| ||Tarantula\'s functionality somewhat overlaps with the on site testing, particularly if you are practicing test-driven development (TDD). Tarantula runs against your actual Web site thereby helping you to identify the problems associated with your production server, user-generated data, and HTML compliance.&lt;br /&gt;
&lt;br /&gt;
A well explained example can be seen at http://www.railslodge.com/plugins/959-tarantula&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| '''Flog[[http://www.brynary.com/2007/9/13/scourging-your-ruby-code-with-flog 12]]'''||Flog is a tool which gives you a profile of your code’s complexity. It can given the complexity pertaining to each method in your code. One can also set threshold for each method using flog &lt;br /&gt;
|-&lt;br /&gt;
| ||The complexity of a code can be important to &lt;br /&gt;
|-&lt;br /&gt;
| ||·         Find the bugs as they are highly probable in complex code areas&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Complex codes can be considered for refactoring&lt;br /&gt;
|-&lt;br /&gt;
| ||A flog report has been explained and shown here http://www.ruby-forum.com/topic/131931&lt;br /&gt;
|-&lt;br /&gt;
| ||&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= C# =&lt;br /&gt;
 &lt;br /&gt;
The list of frameworks that apply for .NET are applied for C#. A long list&lt;br /&gt;
of testing frameworks are available for C# which are NUnit, csUnit, Pex, dotunit,&lt;br /&gt;
VSNUnit, Nester[[http://csharp-source.net/open-source/testing-tools 13]].&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Nunit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''csUnit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''PEX'''&lt;br /&gt;
|-&lt;br /&gt;
| Description||NUnit has been ported from JUnit and has been written completely to take adavntage of the .NET languages.   It is a free open source unit testing tool for all the test-driven development .NET languages including C#.||The major advancements with NUnit are parameterized tests which provides a concise method to express a set of examples that can used to run individual test cases. It has been inspired from JUnit and can be used as an add-in along with the NUnit&lt;br /&gt;
&lt;br /&gt;
||It is a tool to generate efficient unit tests with a high code coverage and are converted to C# automatically. It determines the relevant test inputs for the code hunting for boundary conditions, exceptions and assertion failures. Pex enables Parameterized Unit Testing, an extension of Unit Testing that reduces test maintenance costs. &lt;br /&gt;
|-&lt;br /&gt;
| Examples||http://www.nunit.org/blogs/||http://www.csunit.org/tutorials/tutorial7/||http://research.microsoft.com/en-us/um/redmond/projects/pex/wiki/The%20Hello%20World%20of%20Pex.html&lt;br /&gt;
|-&lt;br /&gt;
| Used as ||Testing framework, GUI and console tool||Testing Framework ,Console tool and VS.NET Add In||It supports NUnit, MbUnit and xUnit.net.Extensions for these test frameworks can be downloaded from the Pex Extensions Project.&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=APPENDIX=&lt;br /&gt;
&lt;br /&gt;
'''1''' '''JUnit''' - JUnit is a unit testing framework for the Java programming language. JUnit has been important in the development of test-driven development, and comprises a family of unit testing frameworks collectively known as xUnit that originated with SUnit. (For more information refer to http://www.junit.org,http://en.wikipedia.org/wiki/Junit)&lt;br /&gt;
&lt;br /&gt;
'''2''' '''XUnit''' - Various code-driven testing frameworks have come to be known collectively as xUnit. These frameworks allow testing of different elements (units) of software, such as functions and classes. (For more information refer to http://en.wikipedia.org/wiki/XUnit)&lt;br /&gt;
&lt;br /&gt;
'''3''' '''unit testing''' - unit testing is a software verification and validation method in which a programmer tests if individual units of source code are fit for use, where a unit is the smallest testable part of an application. For more information refer http://en.wikipedia.org/wiki/Unit_testing&lt;br /&gt;
&lt;br /&gt;
'''4''' '''integration testing''' - is the activity of software testing in which individual software modules are combined and tested as a group. It occurs after unit testing. For more information refer http://en.wikipedia.org/wiki/Integration_testing&lt;br /&gt;
&lt;br /&gt;
'''5''' '''BeforeClass''' - Refer to http://junit.sourceforge.net/javadoc_40/org/junit/BeforeClass.html&lt;br /&gt;
&lt;br /&gt;
'''6''' '''parameterized testing''' - . A parameterized unit test is simply a method that takes parameters, calls the code under test, and states assertions.&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[1]  http://testng.org/doc/documentation-main.html&lt;br /&gt;
&lt;br /&gt;
[2]  http://jakarta.apache.org/cactus/index.html&lt;br /&gt;
&lt;br /&gt;
[3]  http://junit.sourceforge.net/doc/cookbook/cookbook.htm&lt;br /&gt;
&lt;br /&gt;
[4]  http://www.ibm.com/developerworks/java/library/j-cq08296&lt;br /&gt;
&lt;br /&gt;
[5]  http://www.opensourcetesting.org/unit_java.php&lt;br /&gt;
&lt;br /&gt;
[6]  http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle&lt;br /&gt;
&lt;br /&gt;
[7] http://en.wikipedia.org/wiki/Doctest&lt;br /&gt;
&lt;br /&gt;
[8] http://en.wikipedia.org/wiki/Unit_testing&lt;br /&gt;
&lt;br /&gt;
[9] http://www.elctech.com/tutorials/rspec-tutorial&lt;br /&gt;
&lt;br /&gt;
[10] http://www.rubyinside.com/cucumber-the-latest-in-ruby-testing-1342.html&lt;br /&gt;
&lt;br /&gt;
[11] http://www.ruby-forum.com/topic/144083&lt;br /&gt;
&lt;br /&gt;
[12] http://www.brynary.com/2007/9/13/scourging-your-ruby-code-with-flog&lt;br /&gt;
&lt;br /&gt;
[13] http://csharp-source.net/open-source/testing-tools&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b12_AV&amp;diff=22404</id>
		<title>CSC/ECE 517 Fall 2009/wiki1b12 AV</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b12_AV&amp;diff=22404"/>
		<updated>2009-09-29T03:17:01Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* C# */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;XUnit in general, is only one kind of testing framework for object oriented languages. This page talks about the major testing frameworks available for the major object oriented languages such as Java, C++, C#,Python, Ruby and C#. Comparisons have been made wherever possible between the major frameworks available in each language. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Java Testing Frameworks =&lt;br /&gt;
&lt;br /&gt;
Plenty of testing framework exist for Java. JUnit has been the de facto standard for unit testing. However, other frameworks such as TestNG, JTIGER have been built to address various faults and deficiencies with JUnit.  Our primary objective is to compare the various testing frameworks that exist for object oriented languages based on the primary purpose of the framework, features, the platforms on which they operate, etc and thus help in picking up the best testing framework that fits in a particular suitable environment.&lt;br /&gt;
This article DOES NOT introduce JUnit or XUnit. For information on JUnit and XUnit, please refer to the http://www.junit.org or [[http://en.wikipedia.org/wiki/Junit '''APPENDIX 1''']] and [[http://en.wikipedia.org/wiki/XUnit '''APPENDIX 2''']] &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== TestNG Framework ==&lt;br /&gt;
&lt;br /&gt;
TestNG is a testing framework which can help to meet a broad range of testing such as unit testing, integration testing, functional testing, end-to -end testing. (For definition and more information on the different kinds of testing, refer to [[http://en.wikipedia.org/wiki/Unit_testing ''' APPENDIX 3''']] and [[http://en.wikipedia.org/wiki/Integration_testing ''' APPENDIX 4''']]&lt;br /&gt;
&lt;br /&gt;
To write a TestNG test, we need to:&lt;br /&gt;
Write the business logic of the test, and insert the TestNG annotations in them.&lt;br /&gt;
Add the information about our test (such as the class name, the groups we wish to run, etc) in a testing.xml file or in build.xml. &lt;br /&gt;
Run the test.&lt;br /&gt;
TestNG supports data driven testing.(Data-driven testing is a methodology used in Test automation where test scripts are executed and verified based on the data values stored in one or more central data sources or databases. For a detailed description on data driven testing click here: http://en.wikipedia.org/wiki/Data-driven_testing  )&lt;br /&gt;
&lt;br /&gt;
TestNG is invoked in several different ways: &lt;br /&gt;
With a testing.xml file&lt;br /&gt;
ANT&lt;br /&gt;
Command line&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is possible to group the test methods of TestNG.  We can declare methods that belong to these groups and specify groups that contain other groups. It is very flexible as it can help in choosing one set of regular expression and excluding the other sets. This splits the various test groups and there is no need to recompile again if we want to run two different tests back to back.&lt;br /&gt;
&lt;br /&gt;
Requirements:&lt;br /&gt;
JDK 1.4, 1.5&lt;br /&gt;
Invoked in many environments such as command line, ant, ECLIPSE, IDEA, MAVEN, etc&lt;br /&gt;
&lt;br /&gt;
The annotations available in TestNG can be found at:&lt;br /&gt;
http://testng.org/doc/documentation-main.html#annotations&lt;br /&gt;
&lt;br /&gt;
TestNG is inspired from JUnit and Nunit, with additional functionalities such as Flexible test configuration, support for data driven testing, etc.[[http://testng.org/doc/documentation-main.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Cactus ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Cactus is a test framework for testing server-side java code such as Servlets, EJB, etc. It extends J Unit.&lt;br /&gt;
Cactus implements an in-container strategy which means that tests are executed inside the container. &lt;br /&gt;
The Cactus testing unit can be viewed as a system that consists of the following components:&lt;br /&gt;
 &lt;br /&gt;
--Cactus Framework:  This provides the API to write Cactus tests. &lt;br /&gt;
&lt;br /&gt;
--Cactus Integration Modules: They are front ends and frameworks that provide easy ways of using the Cactus Framework. Eg: Eclipse plugin&lt;br /&gt;
&lt;br /&gt;
--Cactus Samples: They demonstrate how to write Cactus tests and how to use a few Integration Modules. [[http://jakarta.apache.org/cactus/index.html 2]]&lt;br /&gt;
&lt;br /&gt;
A useful testing framework provided by Cactus is  integration unit testing.  The tests written for this framework will exercise the interactions with the container. Cactus also provides other frameworks such as code logic unit testing, functional unit testing.&lt;br /&gt;
&lt;br /&gt;
Cactus was developed to fit only integration unit testing with the idea that it is much easier to have to write tests for a single framework than for several. It is believed that Cactus provides a middle ground that provides a high confidence that your code will run when deployed .[[http://jakarta.apache.org/cactus/index.html 2]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To know how it works, click here :&lt;br /&gt;
http://jakarta.apache.org/cactus/how_it_works.html&lt;br /&gt;
&lt;br /&gt;
== '''COMPARISON BETWEEN JUnit,TestNG and Cactus frameworks''' [[http://junit.sourceforge.net/doc/cookbook/cookbook.htm 3]] ==&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''JUnit4'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''TestNG'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Cactus'''&lt;br /&gt;
|-&lt;br /&gt;
| Supporting Type of Testing||Suitable more for Unit testing||Supports Unit testing,Functional testing, end-to-end testing, integration testing ||Primarily unit testing. Also have frameworks for code logic unit testing , functional logic unit testing&lt;br /&gt;
|-&lt;br /&gt;
| Conventions||Rigid  ||Flexible||Not as flexible as TestNG&lt;br /&gt;
|-&lt;br /&gt;
| Derived from JUnit||Yes, from the previous versions||Inspired from Junit,with  added functionalities ||Extends JUnit&lt;br /&gt;
|-&lt;br /&gt;
| Flexibility for large suites||Not flexible for large test suites, ||Flexible for running large test suites of code  and thus one test\'s failure shouldn\'t mean having to rerun a suite of thousands. || No, it is suitable for unit testing.&lt;br /&gt;
|-&lt;br /&gt;
| Suitable for ||Best for a single object||Best for a higher level testing||Best for server-side java code such as Servlets, EJB, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Works with||Command line, ANT,ECLIPSE||Command line,ANT, ECLIPSE, IDEA,MAVEN||ANT&lt;br /&gt;
|-&lt;br /&gt;
| ||||||&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== An example comparing JUNIT 4 and TestNG ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''JUnit 4  v/s TestNG'''&lt;br /&gt;
&lt;br /&gt;
(source: http://www.ibm.com/developerworks/java/library/j-cq08296/) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The frameworks differ is in their core design. JUnit has always been an effective unit-testing framework, meaning that it was built to facilitate testing single objects. TestNG, on the other hand, was built to address testing at higher levels, and consequently, has some features not available in JUnit&lt;br /&gt;
 &lt;br /&gt;
JUnit 4 makes clever use of annotations. JUnit no longer requires you to define a test as a method whose name starts with test, and we can now run fixtures just once as opposed to for each test.  However TestNG established itself as an annotations-based framework long before Junit 4. TestNG pioneered testing with annotations in Java programming, which made it a formidable alternative to JUnit. [[http://www.ibm.com/developerworks/java/library/j-cq08296 4]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Sample J Unit 4 code&lt;br /&gt;
&lt;br /&gt;
 package test.com.acme.dona.dep;&lt;br /&gt;
 import static org.junit.Assert.assertEquals;&lt;br /&gt;
 import static org.junit.Assert.assertNotNull;&lt;br /&gt;
 import org.junit.BeforeClass;&lt;br /&gt;
 import org.junit.Test;&lt;br /&gt;
 public class DependencyFinderTest {&lt;br /&gt;
 private static DependencyFinder finder;&lt;br /&gt;
 @BeforeClass&lt;br /&gt;
 public static void init() throws Exception {&lt;br /&gt;
  finder = new DependencyFinder();&lt;br /&gt;
 }&lt;br /&gt;
 @Test&lt;br /&gt;
 public void verifyDependencies() &lt;br /&gt;
  throws Exception {&lt;br /&gt;
   String targetClss = &lt;br /&gt;
     &amp;quot;test.com.acme.dona.dep.DependencyFind&amp;quot;;&lt;br /&gt;
 Filter[] filtr = new Filter[] { &lt;br /&gt;
      new RegexPackageFilter(&amp;quot;java|junit|org&amp;quot;)};&lt;br /&gt;
 Dependency[] deps = &lt;br /&gt;
      finder.findDependencies(targetClss, filtr);&lt;br /&gt;
 assertNotNull(&amp;quot;deps was null&amp;quot;, deps);&lt;br /&gt;
   assertEquals(&amp;quot;should be 5 large&amp;quot;, 5, deps.length);   &lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
 (source: http://www.ibm.com/developerworks/java/library/j-cq08296/)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Sample TestNG code&lt;br /&gt;
&lt;br /&gt;
 package test.com.acme.dona.dep;&lt;br /&gt;
 import static org.testng.Assert.assertEquals;&lt;br /&gt;
 import static org.testng.Assert.assertNotNull;&lt;br /&gt;
 import org.testng.annotations.BeforeClass;&lt;br /&gt;
 import org.testng.annotations.Configuration;&lt;br /&gt;
 import org.testng.annotations.Test;&lt;br /&gt;
 public class DependencyFinderTest {&lt;br /&gt;
 private DependencyFinder finder;&lt;br /&gt;
 @BeforeClass&lt;br /&gt;
 private void init(){&lt;br /&gt;
  this.finder = new DependencyFinder();&lt;br /&gt;
 }&lt;br /&gt;
 @Test&lt;br /&gt;
 public void verifyDependencies() &lt;br /&gt;
  throws Exception {&lt;br /&gt;
   String targetClss = &lt;br /&gt;
     &amp;quot;test.com.acme.dona.dep.DependencyFind&amp;quot;;&lt;br /&gt;
   Filter[] filtr = new Filter[] { &lt;br /&gt;
      new RegexPackageFilter(&amp;quot;java|junit|org&amp;quot;)};&lt;br /&gt;
   Dependency[] deps = &lt;br /&gt;
      finder.findDependencies(targetClss, filtr);&lt;br /&gt;
   assertNotNull(deps, &amp;quot;deps was null&amp;quot; );&lt;br /&gt;
   assertEquals(5, deps.length, &amp;quot;should be 5 large&amp;quot;);           &lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
 (source: http://www.ibm.com/developerworks/java/library/j-cq08296/)&lt;br /&gt;
&lt;br /&gt;
Both the codes may look a lot similar. However TestNG coding conventions are more flexible than JUnit 4.&lt;br /&gt;
&lt;br /&gt;
JUnit forces us to declare the @BeforeClass (See [[http://junit.sourceforge.net/javadoc_40/org/junit/BeforeClass.html '''APPENDIX 5''']] for more information)  method as static, which consequently requires us to also declare the fixture, finder, as static. We also have to declare the init() method as public. Looking at the TestNG code, you can find that such conventions aren't required. Its init() method is neither static nor public. &lt;br /&gt;
Flexibility has been one of the strong points of TestNG right from the start. JUnit works well for a unit of code, whereas TestNG is better suited for high-level testing. Its flexibility is especially useful with large test suites.[[http://www.ibm.com/developerworks/java/library/j-cq08296 4]]&lt;br /&gt;
&lt;br /&gt;
== Some other JAVA testing units [[http://www.opensourcetesting.org/unit_java.php 5]]  ==&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''JEasyTest'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''J2ME Unit Testing Toolkit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Jailer'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Mockrunner'''&lt;br /&gt;
|-&lt;br /&gt;
| Features||Generates coverage report Allows virtual mock object||Is a  Java 2 Micro Edition (J2ME) library containing a unit testing framework for J2ME||Does test data exporting.  JDBC agnostic  Generates DbUnit datasets, hierarchically structured XML, and topologically sorted SQL-DML.||A lightweight framework for unit testing applications in the J2EE environment.&lt;br /&gt;
|-&lt;br /&gt;
| Integrates with:||ECLIPSE 3.3||ANT ||Platform Independent||OS independent&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Testing frameworks for C++   =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When it comes to unit testing in Java, a unanimous choice would be JUnit. However for C++, there is no one clear winner.  CppUnit is the most widely used tool for C++ which is a part of the XUnit family.&lt;br /&gt;
&lt;br /&gt;
Following is a few basic factors to judge a good testing unit in C++ [[http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle 6]] &lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Features'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''CppUnit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''BOOST.test'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''CxxUnit'''&lt;br /&gt;
|-&lt;br /&gt;
| Minimal amount of work needed to add new tests ||No, and thus a major downfall.||Yes||Yes, very good.&lt;br /&gt;
|-&lt;br /&gt;
| Easy to modify and port ||Medium||Medium||Simplest&lt;br /&gt;
|-&lt;br /&gt;
| Supports setup/teardown steps ||Yes||||Best&lt;br /&gt;
|-&lt;br /&gt;
| Handles exceptions and crashes well.||Yes||Yes, above others||Great support.&lt;br /&gt;
|-&lt;br /&gt;
| Good assert functionality.||Pretty decent.||Yes||Best&lt;br /&gt;
|-&lt;br /&gt;
| Supports different outputs. ||Yes. Comes with IDE friendly output.||Probably, Not trivial to change.||Yes&lt;br /&gt;
|-&lt;br /&gt;
| Supports  suites||Yes.||Yes, but with a big catch. ||Yes&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CppUnit passes most of the above tests , except for the first point and thus needs a lot of code typing.&lt;br /&gt;
Boost.Test isn’t exclusively a unit-testing framework, and is not X Unit based.&lt;br /&gt;
&lt;br /&gt;
Out of the above three , cxxUnit turns out to be a favourite.&lt;br /&gt;
&lt;br /&gt;
It comes close to the requirements of an ideal framework by leveraging the power of an external scripting language. It provides some nifty advanced features and great assert functionality. It does require the use of a scripting language as part of the build process, so those uncomfortable with that requirement, might want to look at one of the other two frameworks.&lt;br /&gt;
&lt;br /&gt;
For work restricted to the PC,  where modifying the framework is not required Boost.Test could  be a very good choice.&lt;br /&gt;
CppUnit , which has come a long way in years is a solid, complete framework  The major drawbacks are the relative verbosity for adding new tests and fixtures. [[http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle 6]]&lt;br /&gt;
&lt;br /&gt;
= Python =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Doctest''': It is a simple, ingenuine technology that allows you to write a narrative in a document which can directly be executed as a test. It is included in Python as a module.&lt;br /&gt;
&lt;br /&gt;
Although doctest makes testing code readable for non-programmers ,the simplicity of a narrative test like doctest is accompanied by it’s own flaws .Some of the disadvantages of using doctest are&lt;br /&gt;
&lt;br /&gt;
•	These tests are difficult to handle in case of failures as they are more generic. Specific tests are narrower and better in communicating intent and ensuring coverage.&lt;br /&gt;
&lt;br /&gt;
•	The test code is executed in a special way thus making it difficult to reason about how it will be executed. It is also harder to program around the tests.&lt;br /&gt;
&lt;br /&gt;
•	It is actually difficult to get an outline of the tests at glance. There’s no tool that can give an overview of the unit tests in a doc test file [[http://en.wikipedia.org/wiki/Doctest 7]].&lt;br /&gt;
&lt;br /&gt;
An detailed information about doctest with thorough examples can be read at http://docs.python.org/library/doctest.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Unittest''': Unittest are more specific tests which are more functional in nature allowing it to be written for individual functions or the class as a whole. &lt;br /&gt;
&lt;br /&gt;
The fact that Unittest is based on jUnit makes people with the xUnit familiarity pick it up really quick hence it is more Java based than python .It has been introduced in the Python’s library since version 2.1 &lt;br /&gt;
&lt;br /&gt;
The disadvantages of using the unit test are &lt;br /&gt;
&lt;br /&gt;
•	The tests have a different look and feel with respect to the code under test&lt;br /&gt;
&lt;br /&gt;
•	The assertions used in the text use custom syntax which makes it difficult&lt;br /&gt;
&lt;br /&gt;
•	The test code is difficult to understand compared to the Doctest and the strong basis on jUnit makes it difficult for the pure Python coders [[http://en.wikipedia.org/wiki/Unit_testing 8]]&lt;br /&gt;
&lt;br /&gt;
A detailed information about doctest with thorough examples can be read at http://docs.python.org/library/unittest.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Doctest vs Unittest'''&lt;br /&gt;
&lt;br /&gt;
Here we compare simple features of both the tests thus giving us an idea of which one to use based on the requirement&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''doctest'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''unittest'''&lt;br /&gt;
|-&lt;br /&gt;
| '''Simplicity'''||Best suited for novice programmers||A little complex to use specially if unaware of Junit&lt;br /&gt;
|-&lt;br /&gt;
| '''Documentation'''||Better Narratives||Tests have little or no comments&lt;br /&gt;
|-&lt;br /&gt;
| '''Comprehensive testing'''||Doctests get clutterd for comprehensive tests and thus less readable||Best suited for comprehensive tests&lt;br /&gt;
|-&lt;br /&gt;
| '''Flexibility and Control'''||Less flexible||More flexible&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Ruby =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The basic testing framework for RUBY is xUnit . There are some frameworks which have evolved over the years which include RSpec, Trantula, Flog, RunCodeRun, Cucumber etc. We’ll talk about each of them in brief&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Testing Framework'''&lt;br /&gt;
| style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Description'''&lt;br /&gt;
|-&lt;br /&gt;
| '''Rspec[[http://www.elctech.com/tutorials/rspec-tutorial 9]]'''||It is Behavior Driven Development whose basic features are&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Behavior counts first, testing follows&lt;br /&gt;
|-&lt;br /&gt;
| ||·         It focuses more on business values&lt;br /&gt;
|-&lt;br /&gt;
| ||·         It’s more about getting the words right rather than just writing the test first&lt;br /&gt;
|-&lt;br /&gt;
| ||Advantages:&lt;br /&gt;
|-&lt;br /&gt;
| ||·         These are extremely easy to read and makes sense to a non-programmer&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Rspec lets you unit test while also providing mocking and stubbing support&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Rspec can help with the coverage tests using Rcov&lt;br /&gt;
|-&lt;br /&gt;
| ||·         One can also perform integration test using Rspec &lt;br /&gt;
|-&lt;br /&gt;
| ||Disadvantages:&lt;br /&gt;
|-&lt;br /&gt;
| ||·         It involves a lot of behind the scene metaprogramming which makes the tests very difficult to understand&lt;br /&gt;
|-&lt;br /&gt;
| ||A simple Rspec example can be read at http://rspec.info/&lt;br /&gt;
|-&lt;br /&gt;
| '''Cucumber[[http://www.rubyinside.com/cucumber-the-latest-in-ruby-testing-1342.html 10]]'''||Cucumber, the latest addition to the Rspec family allows one to execute documentation written in plain text(known as ‘stories’)&lt;br /&gt;
|-&lt;br /&gt;
| ||A very good example of writing a test in cucumber can be read at http://cukes.info/&lt;br /&gt;
|-&lt;br /&gt;
| ||&lt;br /&gt;
|-&lt;br /&gt;
| '''Tarantula[[http://www.ruby-forum.com/topic/144083 11]]'''||Tarantula is a Rail’s plugin that produces a detailed report describing the URL’s that it has crawled across and the responses that it received from each one of them.&lt;br /&gt;
|-&lt;br /&gt;
| ||Tarantula\'s functionality somewhat overlaps with the on site testing, particularly if you are practicing test-driven development (TDD). Tarantula runs against your actual Web site thereby helping you to identify the problems associated with your production server, user-generated data, and HTML compliance.&lt;br /&gt;
&lt;br /&gt;
A well explained example can be seen at http://www.railslodge.com/plugins/959-tarantula&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| '''Flog[[http://www.brynary.com/2007/9/13/scourging-your-ruby-code-with-flog 12]]'''||Flog is a tool which gives you a profile of your code’s complexity. It can given the complexity pertaining to each method in your code. One can also set threshold for each method using flog &lt;br /&gt;
|-&lt;br /&gt;
| ||The complexity of a code can be important to &lt;br /&gt;
|-&lt;br /&gt;
| ||·         Find the bugs as they are highly probable in complex code areas&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Complex codes can be considered for refactoring&lt;br /&gt;
|-&lt;br /&gt;
| ||A flog report has been explained and shown here http://www.ruby-forum.com/topic/131931&lt;br /&gt;
|-&lt;br /&gt;
| ||&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= C# =&lt;br /&gt;
 &lt;br /&gt;
The list of frameworks that apply for .NET are applied for C#. A long list&lt;br /&gt;
of testing frameworks are available for C# which are NUnit, csUnit, Pex, dotunit,&lt;br /&gt;
VSNUnit, Nester[[http://csharp-source.net/open-source/testing-tools 13]].&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Nunit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''csUnit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''PEX'''&lt;br /&gt;
|-&lt;br /&gt;
| Description||NUnit has been ported from JUnit and has been written completely to take adavntage of the .NET languages.   It is a free open source unit testing tool for all the test-driven development .NET languages including C#.||The major advancements with NUnit are parameterized tests which provides a concise method to express a set of examples that can used to run individual test cases. It has been inspired from JUnit and can be used as an add-in along with the NUnit&lt;br /&gt;
&lt;br /&gt;
||It is a tool to generate efficient unit tests with a high code coverage and are converted to C# automatically. It determines the relevant test inputs for the code hunting for boundary conditions, exceptions and assertion failures. Pex enables Parameterized Unit Testing, an extension of Unit Testing that reduces test maintenance costs. &lt;br /&gt;
|-&lt;br /&gt;
| Examples||http://www.nunit.org/blogs/||http://www.csunit.org/tutorials/tutorial7/||http://research.microsoft.com/en-us/um/redmond/projects/pex/wiki/The%20Hello%20World%20of%20Pex.html&lt;br /&gt;
|-&lt;br /&gt;
| Used as ||Testing framework, GUI and console tool||Testing Framework ,Console tool and VS.NET Add In||It supports NUnit, MbUnit and xUnit.net.Extensions for these test frameworks can be downloaded from the Pex Extensions Project.&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=APPENDIX=&lt;br /&gt;
&lt;br /&gt;
'''1''' '''JUnit''' - JUnit is a unit testing framework for the Java programming language. JUnit has been important in the development of test-driven development, and comprises a family of unit testing frameworks collectively known as xUnit that originated with SUnit. (For more information refer to http://www.junit.org,http://en.wikipedia.org/wiki/Junit)&lt;br /&gt;
&lt;br /&gt;
'''2''' '''XUnit''' - Various code-driven testing frameworks have come to be known collectively as xUnit. These frameworks allow testing of different elements (units) of software, such as functions and classes. (For more information refer to http://en.wikipedia.org/wiki/XUnit)&lt;br /&gt;
&lt;br /&gt;
'''3''' '''unit testing''' - unit testing is a software verification and validation method in which a programmer tests if individual units of source code are fit for use, where a unit is the smallest testable part of an application. For more information refer http://en.wikipedia.org/wiki/Unit_testing&lt;br /&gt;
&lt;br /&gt;
'''4''' '''integration testing''' - is the activity of software testing in which individual software modules are combined and tested as a group. It occurs after unit testing. For more information refer http://en.wikipedia.org/wiki/Integration_testing&lt;br /&gt;
&lt;br /&gt;
'''5''' '''BeforeClass''' - Refer to http://junit.sourceforge.net/javadoc_40/org/junit/BeforeClass.html&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[1]  http://testng.org/doc/documentation-main.html&lt;br /&gt;
&lt;br /&gt;
[2]  http://jakarta.apache.org/cactus/index.html&lt;br /&gt;
&lt;br /&gt;
[3]  http://junit.sourceforge.net/doc/cookbook/cookbook.htm&lt;br /&gt;
&lt;br /&gt;
[4]  http://www.ibm.com/developerworks/java/library/j-cq08296&lt;br /&gt;
&lt;br /&gt;
[5]  http://www.opensourcetesting.org/unit_java.php&lt;br /&gt;
&lt;br /&gt;
[6]  http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle&lt;br /&gt;
&lt;br /&gt;
[7] http://en.wikipedia.org/wiki/Doctest&lt;br /&gt;
&lt;br /&gt;
[8] http://en.wikipedia.org/wiki/Unit_testing&lt;br /&gt;
&lt;br /&gt;
[9] http://www.elctech.com/tutorials/rspec-tutorial&lt;br /&gt;
&lt;br /&gt;
[10] http://www.rubyinside.com/cucumber-the-latest-in-ruby-testing-1342.html&lt;br /&gt;
&lt;br /&gt;
[11] http://www.ruby-forum.com/topic/144083&lt;br /&gt;
&lt;br /&gt;
[12] http://www.brynary.com/2007/9/13/scourging-your-ruby-code-with-flog&lt;br /&gt;
&lt;br /&gt;
[13] http://csharp-source.net/open-source/testing-tools&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b12_AV&amp;diff=22403</id>
		<title>CSC/ECE 517 Fall 2009/wiki1b12 AV</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b12_AV&amp;diff=22403"/>
		<updated>2009-09-29T03:15:27Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;XUnit in general, is only one kind of testing framework for object oriented languages. This page talks about the major testing frameworks available for the major object oriented languages such as Java, C++, C#,Python, Ruby and C#. Comparisons have been made wherever possible between the major frameworks available in each language. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Java Testing Frameworks =&lt;br /&gt;
&lt;br /&gt;
Plenty of testing framework exist for Java. JUnit has been the de facto standard for unit testing. However, other frameworks such as TestNG, JTIGER have been built to address various faults and deficiencies with JUnit.  Our primary objective is to compare the various testing frameworks that exist for object oriented languages based on the primary purpose of the framework, features, the platforms on which they operate, etc and thus help in picking up the best testing framework that fits in a particular suitable environment.&lt;br /&gt;
This article DOES NOT introduce JUnit or XUnit. For information on JUnit and XUnit, please refer to the http://www.junit.org or [[http://en.wikipedia.org/wiki/Junit '''APPENDIX 1''']] and [[http://en.wikipedia.org/wiki/XUnit '''APPENDIX 2''']] &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== TestNG Framework ==&lt;br /&gt;
&lt;br /&gt;
TestNG is a testing framework which can help to meet a broad range of testing such as unit testing, integration testing, functional testing, end-to -end testing. (For definition and more information on the different kinds of testing, refer to [[http://en.wikipedia.org/wiki/Unit_testing ''' APPENDIX 3''']] and [[http://en.wikipedia.org/wiki/Integration_testing ''' APPENDIX 4''']]&lt;br /&gt;
&lt;br /&gt;
To write a TestNG test, we need to:&lt;br /&gt;
Write the business logic of the test, and insert the TestNG annotations in them.&lt;br /&gt;
Add the information about our test (such as the class name, the groups we wish to run, etc) in a testing.xml file or in build.xml. &lt;br /&gt;
Run the test.&lt;br /&gt;
TestNG supports data driven testing.(Data-driven testing is a methodology used in Test automation where test scripts are executed and verified based on the data values stored in one or more central data sources or databases. For a detailed description on data driven testing click here: http://en.wikipedia.org/wiki/Data-driven_testing  )&lt;br /&gt;
&lt;br /&gt;
TestNG is invoked in several different ways: &lt;br /&gt;
With a testing.xml file&lt;br /&gt;
ANT&lt;br /&gt;
Command line&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is possible to group the test methods of TestNG.  We can declare methods that belong to these groups and specify groups that contain other groups. It is very flexible as it can help in choosing one set of regular expression and excluding the other sets. This splits the various test groups and there is no need to recompile again if we want to run two different tests back to back.&lt;br /&gt;
&lt;br /&gt;
Requirements:&lt;br /&gt;
JDK 1.4, 1.5&lt;br /&gt;
Invoked in many environments such as command line, ant, ECLIPSE, IDEA, MAVEN, etc&lt;br /&gt;
&lt;br /&gt;
The annotations available in TestNG can be found at:&lt;br /&gt;
http://testng.org/doc/documentation-main.html#annotations&lt;br /&gt;
&lt;br /&gt;
TestNG is inspired from JUnit and Nunit, with additional functionalities such as Flexible test configuration, support for data driven testing, etc.[[http://testng.org/doc/documentation-main.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Cactus ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Cactus is a test framework for testing server-side java code such as Servlets, EJB, etc. It extends J Unit.&lt;br /&gt;
Cactus implements an in-container strategy which means that tests are executed inside the container. &lt;br /&gt;
The Cactus testing unit can be viewed as a system that consists of the following components:&lt;br /&gt;
 &lt;br /&gt;
--Cactus Framework:  This provides the API to write Cactus tests. &lt;br /&gt;
&lt;br /&gt;
--Cactus Integration Modules: They are front ends and frameworks that provide easy ways of using the Cactus Framework. Eg: Eclipse plugin&lt;br /&gt;
&lt;br /&gt;
--Cactus Samples: They demonstrate how to write Cactus tests and how to use a few Integration Modules. [[http://jakarta.apache.org/cactus/index.html 2]]&lt;br /&gt;
&lt;br /&gt;
A useful testing framework provided by Cactus is  integration unit testing.  The tests written for this framework will exercise the interactions with the container. Cactus also provides other frameworks such as code logic unit testing, functional unit testing.&lt;br /&gt;
&lt;br /&gt;
Cactus was developed to fit only integration unit testing with the idea that it is much easier to have to write tests for a single framework than for several. It is believed that Cactus provides a middle ground that provides a high confidence that your code will run when deployed .[[http://jakarta.apache.org/cactus/index.html 2]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To know how it works, click here :&lt;br /&gt;
http://jakarta.apache.org/cactus/how_it_works.html&lt;br /&gt;
&lt;br /&gt;
== '''COMPARISON BETWEEN JUnit,TestNG and Cactus frameworks''' [[http://junit.sourceforge.net/doc/cookbook/cookbook.htm 3]] ==&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''JUnit4'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''TestNG'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Cactus'''&lt;br /&gt;
|-&lt;br /&gt;
| Supporting Type of Testing||Suitable more for Unit testing||Supports Unit testing,Functional testing, end-to-end testing, integration testing ||Primarily unit testing. Also have frameworks for code logic unit testing , functional logic unit testing&lt;br /&gt;
|-&lt;br /&gt;
| Conventions||Rigid  ||Flexible||Not as flexible as TestNG&lt;br /&gt;
|-&lt;br /&gt;
| Derived from JUnit||Yes, from the previous versions||Inspired from Junit,with  added functionalities ||Extends JUnit&lt;br /&gt;
|-&lt;br /&gt;
| Flexibility for large suites||Not flexible for large test suites, ||Flexible for running large test suites of code  and thus one test\'s failure shouldn\'t mean having to rerun a suite of thousands. || No, it is suitable for unit testing.&lt;br /&gt;
|-&lt;br /&gt;
| Suitable for ||Best for a single object||Best for a higher level testing||Best for server-side java code such as Servlets, EJB, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Works with||Command line, ANT,ECLIPSE||Command line,ANT, ECLIPSE, IDEA,MAVEN||ANT&lt;br /&gt;
|-&lt;br /&gt;
| ||||||&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== An example comparing JUNIT 4 and TestNG ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''JUnit 4  v/s TestNG'''&lt;br /&gt;
&lt;br /&gt;
(source: http://www.ibm.com/developerworks/java/library/j-cq08296/) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The frameworks differ is in their core design. JUnit has always been an effective unit-testing framework, meaning that it was built to facilitate testing single objects. TestNG, on the other hand, was built to address testing at higher levels, and consequently, has some features not available in JUnit&lt;br /&gt;
 &lt;br /&gt;
JUnit 4 makes clever use of annotations. JUnit no longer requires you to define a test as a method whose name starts with test, and we can now run fixtures just once as opposed to for each test.  However TestNG established itself as an annotations-based framework long before Junit 4. TestNG pioneered testing with annotations in Java programming, which made it a formidable alternative to JUnit. [[http://www.ibm.com/developerworks/java/library/j-cq08296 4]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Sample J Unit 4 code&lt;br /&gt;
&lt;br /&gt;
 package test.com.acme.dona.dep;&lt;br /&gt;
 import static org.junit.Assert.assertEquals;&lt;br /&gt;
 import static org.junit.Assert.assertNotNull;&lt;br /&gt;
 import org.junit.BeforeClass;&lt;br /&gt;
 import org.junit.Test;&lt;br /&gt;
 public class DependencyFinderTest {&lt;br /&gt;
 private static DependencyFinder finder;&lt;br /&gt;
 @BeforeClass&lt;br /&gt;
 public static void init() throws Exception {&lt;br /&gt;
  finder = new DependencyFinder();&lt;br /&gt;
 }&lt;br /&gt;
 @Test&lt;br /&gt;
 public void verifyDependencies() &lt;br /&gt;
  throws Exception {&lt;br /&gt;
   String targetClss = &lt;br /&gt;
     &amp;quot;test.com.acme.dona.dep.DependencyFind&amp;quot;;&lt;br /&gt;
 Filter[] filtr = new Filter[] { &lt;br /&gt;
      new RegexPackageFilter(&amp;quot;java|junit|org&amp;quot;)};&lt;br /&gt;
 Dependency[] deps = &lt;br /&gt;
      finder.findDependencies(targetClss, filtr);&lt;br /&gt;
 assertNotNull(&amp;quot;deps was null&amp;quot;, deps);&lt;br /&gt;
   assertEquals(&amp;quot;should be 5 large&amp;quot;, 5, deps.length);   &lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
 (source: http://www.ibm.com/developerworks/java/library/j-cq08296/)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Sample TestNG code&lt;br /&gt;
&lt;br /&gt;
 package test.com.acme.dona.dep;&lt;br /&gt;
 import static org.testng.Assert.assertEquals;&lt;br /&gt;
 import static org.testng.Assert.assertNotNull;&lt;br /&gt;
 import org.testng.annotations.BeforeClass;&lt;br /&gt;
 import org.testng.annotations.Configuration;&lt;br /&gt;
 import org.testng.annotations.Test;&lt;br /&gt;
 public class DependencyFinderTest {&lt;br /&gt;
 private DependencyFinder finder;&lt;br /&gt;
 @BeforeClass&lt;br /&gt;
 private void init(){&lt;br /&gt;
  this.finder = new DependencyFinder();&lt;br /&gt;
 }&lt;br /&gt;
 @Test&lt;br /&gt;
 public void verifyDependencies() &lt;br /&gt;
  throws Exception {&lt;br /&gt;
   String targetClss = &lt;br /&gt;
     &amp;quot;test.com.acme.dona.dep.DependencyFind&amp;quot;;&lt;br /&gt;
   Filter[] filtr = new Filter[] { &lt;br /&gt;
      new RegexPackageFilter(&amp;quot;java|junit|org&amp;quot;)};&lt;br /&gt;
   Dependency[] deps = &lt;br /&gt;
      finder.findDependencies(targetClss, filtr);&lt;br /&gt;
   assertNotNull(deps, &amp;quot;deps was null&amp;quot; );&lt;br /&gt;
   assertEquals(5, deps.length, &amp;quot;should be 5 large&amp;quot;);           &lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
 (source: http://www.ibm.com/developerworks/java/library/j-cq08296/)&lt;br /&gt;
&lt;br /&gt;
Both the codes may look a lot similar. However TestNG coding conventions are more flexible than JUnit 4.&lt;br /&gt;
&lt;br /&gt;
JUnit forces us to declare the @BeforeClass (See [[http://junit.sourceforge.net/javadoc_40/org/junit/BeforeClass.html '''APPENDIX 5''']] for more information)  method as static, which consequently requires us to also declare the fixture, finder, as static. We also have to declare the init() method as public. Looking at the TestNG code, you can find that such conventions aren't required. Its init() method is neither static nor public. &lt;br /&gt;
Flexibility has been one of the strong points of TestNG right from the start. JUnit works well for a unit of code, whereas TestNG is better suited for high-level testing. Its flexibility is especially useful with large test suites.[[http://www.ibm.com/developerworks/java/library/j-cq08296 4]]&lt;br /&gt;
&lt;br /&gt;
== Some other JAVA testing units [[http://www.opensourcetesting.org/unit_java.php 5]]  ==&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''JEasyTest'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''J2ME Unit Testing Toolkit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Jailer'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Mockrunner'''&lt;br /&gt;
|-&lt;br /&gt;
| Features||Generates coverage report Allows virtual mock object||Is a  Java 2 Micro Edition (J2ME) library containing a unit testing framework for J2ME||Does test data exporting.  JDBC agnostic  Generates DbUnit datasets, hierarchically structured XML, and topologically sorted SQL-DML.||A lightweight framework for unit testing applications in the J2EE environment.&lt;br /&gt;
|-&lt;br /&gt;
| Integrates with:||ECLIPSE 3.3||ANT ||Platform Independent||OS independent&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Testing frameworks for C++   =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When it comes to unit testing in Java, a unanimous choice would be JUnit. However for C++, there is no one clear winner.  CppUnit is the most widely used tool for C++ which is a part of the XUnit family.&lt;br /&gt;
&lt;br /&gt;
Following is a few basic factors to judge a good testing unit in C++ [[http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle 6]] &lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Features'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''CppUnit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''BOOST.test'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''CxxUnit'''&lt;br /&gt;
|-&lt;br /&gt;
| Minimal amount of work needed to add new tests ||No, and thus a major downfall.||Yes||Yes, very good.&lt;br /&gt;
|-&lt;br /&gt;
| Easy to modify and port ||Medium||Medium||Simplest&lt;br /&gt;
|-&lt;br /&gt;
| Supports setup/teardown steps ||Yes||||Best&lt;br /&gt;
|-&lt;br /&gt;
| Handles exceptions and crashes well.||Yes||Yes, above others||Great support.&lt;br /&gt;
|-&lt;br /&gt;
| Good assert functionality.||Pretty decent.||Yes||Best&lt;br /&gt;
|-&lt;br /&gt;
| Supports different outputs. ||Yes. Comes with IDE friendly output.||Probably, Not trivial to change.||Yes&lt;br /&gt;
|-&lt;br /&gt;
| Supports  suites||Yes.||Yes, but with a big catch. ||Yes&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CppUnit passes most of the above tests , except for the first point and thus needs a lot of code typing.&lt;br /&gt;
Boost.Test isn’t exclusively a unit-testing framework, and is not X Unit based.&lt;br /&gt;
&lt;br /&gt;
Out of the above three , cxxUnit turns out to be a favourite.&lt;br /&gt;
&lt;br /&gt;
It comes close to the requirements of an ideal framework by leveraging the power of an external scripting language. It provides some nifty advanced features and great assert functionality. It does require the use of a scripting language as part of the build process, so those uncomfortable with that requirement, might want to look at one of the other two frameworks.&lt;br /&gt;
&lt;br /&gt;
For work restricted to the PC,  where modifying the framework is not required Boost.Test could  be a very good choice.&lt;br /&gt;
CppUnit , which has come a long way in years is a solid, complete framework  The major drawbacks are the relative verbosity for adding new tests and fixtures. [[http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle 6]]&lt;br /&gt;
&lt;br /&gt;
= Python =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Doctest''': It is a simple, ingenuine technology that allows you to write a narrative in a document which can directly be executed as a test. It is included in Python as a module.&lt;br /&gt;
&lt;br /&gt;
Although doctest makes testing code readable for non-programmers ,the simplicity of a narrative test like doctest is accompanied by it’s own flaws .Some of the disadvantages of using doctest are&lt;br /&gt;
&lt;br /&gt;
•	These tests are difficult to handle in case of failures as they are more generic. Specific tests are narrower and better in communicating intent and ensuring coverage.&lt;br /&gt;
&lt;br /&gt;
•	The test code is executed in a special way thus making it difficult to reason about how it will be executed. It is also harder to program around the tests.&lt;br /&gt;
&lt;br /&gt;
•	It is actually difficult to get an outline of the tests at glance. There’s no tool that can give an overview of the unit tests in a doc test file [[http://en.wikipedia.org/wiki/Doctest 7]].&lt;br /&gt;
&lt;br /&gt;
An detailed information about doctest with thorough examples can be read at http://docs.python.org/library/doctest.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Unittest''': Unittest are more specific tests which are more functional in nature allowing it to be written for individual functions or the class as a whole. &lt;br /&gt;
&lt;br /&gt;
The fact that Unittest is based on jUnit makes people with the xUnit familiarity pick it up really quick hence it is more Java based than python .It has been introduced in the Python’s library since version 2.1 &lt;br /&gt;
&lt;br /&gt;
The disadvantages of using the unit test are &lt;br /&gt;
&lt;br /&gt;
•	The tests have a different look and feel with respect to the code under test&lt;br /&gt;
&lt;br /&gt;
•	The assertions used in the text use custom syntax which makes it difficult&lt;br /&gt;
&lt;br /&gt;
•	The test code is difficult to understand compared to the Doctest and the strong basis on jUnit makes it difficult for the pure Python coders [[http://en.wikipedia.org/wiki/Unit_testing 8]]&lt;br /&gt;
&lt;br /&gt;
A detailed information about doctest with thorough examples can be read at http://docs.python.org/library/unittest.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Doctest vs Unittest'''&lt;br /&gt;
&lt;br /&gt;
Here we compare simple features of both the tests thus giving us an idea of which one to use based on the requirement&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''doctest'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''unittest'''&lt;br /&gt;
|-&lt;br /&gt;
| '''Simplicity'''||Best suited for novice programmers||A little complex to use specially if unaware of Junit&lt;br /&gt;
|-&lt;br /&gt;
| '''Documentation'''||Better Narratives||Tests have little or no comments&lt;br /&gt;
|-&lt;br /&gt;
| '''Comprehensive testing'''||Doctests get clutterd for comprehensive tests and thus less readable||Best suited for comprehensive tests&lt;br /&gt;
|-&lt;br /&gt;
| '''Flexibility and Control'''||Less flexible||More flexible&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Ruby =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The basic testing framework for RUBY is xUnit . There are some frameworks which have evolved over the years which include RSpec, Trantula, Flog, RunCodeRun, Cucumber etc. We’ll talk about each of them in brief&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Testing Framework'''&lt;br /&gt;
| style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Description'''&lt;br /&gt;
|-&lt;br /&gt;
| '''Rspec[[http://www.elctech.com/tutorials/rspec-tutorial 9]]'''||It is Behavior Driven Development whose basic features are&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Behavior counts first, testing follows&lt;br /&gt;
|-&lt;br /&gt;
| ||·         It focuses more on business values&lt;br /&gt;
|-&lt;br /&gt;
| ||·         It’s more about getting the words right rather than just writing the test first&lt;br /&gt;
|-&lt;br /&gt;
| ||Advantages:&lt;br /&gt;
|-&lt;br /&gt;
| ||·         These are extremely easy to read and makes sense to a non-programmer&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Rspec lets you unit test while also providing mocking and stubbing support&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Rspec can help with the coverage tests using Rcov&lt;br /&gt;
|-&lt;br /&gt;
| ||·         One can also perform integration test using Rspec &lt;br /&gt;
|-&lt;br /&gt;
| ||Disadvantages:&lt;br /&gt;
|-&lt;br /&gt;
| ||·         It involves a lot of behind the scene metaprogramming which makes the tests very difficult to understand&lt;br /&gt;
|-&lt;br /&gt;
| ||A simple Rspec example can be read at http://rspec.info/&lt;br /&gt;
|-&lt;br /&gt;
| '''Cucumber[[http://www.rubyinside.com/cucumber-the-latest-in-ruby-testing-1342.html 10]]'''||Cucumber, the latest addition to the Rspec family allows one to execute documentation written in plain text(known as ‘stories’)&lt;br /&gt;
|-&lt;br /&gt;
| ||A very good example of writing a test in cucumber can be read at http://cukes.info/&lt;br /&gt;
|-&lt;br /&gt;
| ||&lt;br /&gt;
|-&lt;br /&gt;
| '''Tarantula[[http://www.ruby-forum.com/topic/144083 11]]'''||Tarantula is a Rail’s plugin that produces a detailed report describing the URL’s that it has crawled across and the responses that it received from each one of them.&lt;br /&gt;
|-&lt;br /&gt;
| ||Tarantula\'s functionality somewhat overlaps with the on site testing, particularly if you are practicing test-driven development (TDD). Tarantula runs against your actual Web site thereby helping you to identify the problems associated with your production server, user-generated data, and HTML compliance.&lt;br /&gt;
&lt;br /&gt;
A well explained example can be seen at http://www.railslodge.com/plugins/959-tarantula&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| '''Flog[[http://www.brynary.com/2007/9/13/scourging-your-ruby-code-with-flog 12]]'''||Flog is a tool which gives you a profile of your code’s complexity. It can given the complexity pertaining to each method in your code. One can also set threshold for each method using flog &lt;br /&gt;
|-&lt;br /&gt;
| ||The complexity of a code can be important to &lt;br /&gt;
|-&lt;br /&gt;
| ||·         Find the bugs as they are highly probable in complex code areas&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Complex codes can be considered for refactoring&lt;br /&gt;
|-&lt;br /&gt;
| ||A flog report has been explained and shown here http://www.ruby-forum.com/topic/131931&lt;br /&gt;
|-&lt;br /&gt;
| ||&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= C# =&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
The list of frameworks that apply for .NET are applied for C#. A long list of testing frameworks are available for C# which are csUnit, NUnit, dotunit, VSNUnit, Nester[[http://csharp-source.net/open-source/testing-tools 13]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''NUnit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''csUnit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Systin'''&lt;br /&gt;
|-&lt;br /&gt;
| Description||NUnit has been ported from JUnit and has been written completely to take the advantage of the .NET languages.||It is a free open source unit testing tool for all the test-driven development .NET languages including C#. ||Systin creates a domain specific testing language which allows an automatic testing of applications at the system level.&lt;br /&gt;
|-&lt;br /&gt;
| ||The major advancements with NUnit are parameterized tests which provides a concise method to express a set of examples that can used to run  individual test cases.||It has been inspired from JUnit and can be used as an add-in along with the NUnit||The tests can be written in a simple document which can be converted to a .net language driver class&lt;br /&gt;
|-&lt;br /&gt;
| Examples||http://www.nunit.org/blogs/||http://www.csunit.org/tutorials/tutorial7/||&lt;br /&gt;
|-&lt;br /&gt;
| ||||||&lt;br /&gt;
|-&lt;br /&gt;
| Used as||Testing framework, GUI and console tool||Testing Framework , Console tool and VS.NET Add In||&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=APPENDIX=&lt;br /&gt;
&lt;br /&gt;
'''1''' '''JUnit''' - JUnit is a unit testing framework for the Java programming language. JUnit has been important in the development of test-driven development, and comprises a family of unit testing frameworks collectively known as xUnit that originated with SUnit. (For more information refer to http://www.junit.org,http://en.wikipedia.org/wiki/Junit)&lt;br /&gt;
&lt;br /&gt;
'''2''' '''XUnit''' - Various code-driven testing frameworks have come to be known collectively as xUnit. These frameworks allow testing of different elements (units) of software, such as functions and classes. (For more information refer to http://en.wikipedia.org/wiki/XUnit)&lt;br /&gt;
&lt;br /&gt;
'''3''' '''unit testing''' - unit testing is a software verification and validation method in which a programmer tests if individual units of source code are fit for use, where a unit is the smallest testable part of an application. For more information refer http://en.wikipedia.org/wiki/Unit_testing&lt;br /&gt;
&lt;br /&gt;
'''4''' '''integration testing''' - is the activity of software testing in which individual software modules are combined and tested as a group. It occurs after unit testing. For more information refer http://en.wikipedia.org/wiki/Integration_testing&lt;br /&gt;
&lt;br /&gt;
'''5''' '''BeforeClass''' - Refer to http://junit.sourceforge.net/javadoc_40/org/junit/BeforeClass.html&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[1]  http://testng.org/doc/documentation-main.html&lt;br /&gt;
&lt;br /&gt;
[2]  http://jakarta.apache.org/cactus/index.html&lt;br /&gt;
&lt;br /&gt;
[3]  http://junit.sourceforge.net/doc/cookbook/cookbook.htm&lt;br /&gt;
&lt;br /&gt;
[4]  http://www.ibm.com/developerworks/java/library/j-cq08296&lt;br /&gt;
&lt;br /&gt;
[5]  http://www.opensourcetesting.org/unit_java.php&lt;br /&gt;
&lt;br /&gt;
[6]  http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle&lt;br /&gt;
&lt;br /&gt;
[7] http://en.wikipedia.org/wiki/Doctest&lt;br /&gt;
&lt;br /&gt;
[8] http://en.wikipedia.org/wiki/Unit_testing&lt;br /&gt;
&lt;br /&gt;
[9] http://www.elctech.com/tutorials/rspec-tutorial&lt;br /&gt;
&lt;br /&gt;
[10] http://www.rubyinside.com/cucumber-the-latest-in-ruby-testing-1342.html&lt;br /&gt;
&lt;br /&gt;
[11] http://www.ruby-forum.com/topic/144083&lt;br /&gt;
&lt;br /&gt;
[12] http://www.brynary.com/2007/9/13/scourging-your-ruby-code-with-flog&lt;br /&gt;
&lt;br /&gt;
[13] http://csharp-source.net/open-source/testing-tools&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b12_AV&amp;diff=22402</id>
		<title>CSC/ECE 517 Fall 2009/wiki1b12 AV</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b12_AV&amp;diff=22402"/>
		<updated>2009-09-29T03:02:05Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* Cactus */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;XUnit in general, is only one kind of testing framework for object oriented&lt;br /&gt;
languages. This page talks about the major testing frameworks available for&lt;br /&gt;
the major object oriented languages such as Java, C++, C#,Python, Ruby and&lt;br /&gt;
C#. Comparisons have been made wherever possible between the major&lt;br /&gt;
frameworks available in each language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Java Testing Frameworks =&lt;br /&gt;
&lt;br /&gt;
Plenty of testing framework exist for Java. JUnit has been the de facto&lt;br /&gt;
standard for unit testing. However, other frameworks such as TestNG, JTIGER&lt;br /&gt;
have been built to address various faults and deficiencies with JUnit.  Our&lt;br /&gt;
primary objective is to compare the various testing frameworks that exist&lt;br /&gt;
for object oriented languages based on the primary purpose of the framework,&lt;br /&gt;
features, the platforms on which they operate, etc and thus help in picking&lt;br /&gt;
up the best testing framework that fits in a particular suitable&lt;br /&gt;
environment.&lt;br /&gt;
This article DOES NOT introduce JUnit or XUnit. For information on JUnit,&lt;br /&gt;
please refer to http://www.junit.org or [[http://en.wikipedia.org/wiki/Junit '''APPENDIX 1''']]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== TestNG Framework ==&lt;br /&gt;
&lt;br /&gt;
TestNG is a testing framework which can help to meet a broad range of&lt;br /&gt;
testing such as unit testing, integration testing, functional testing,&lt;br /&gt;
end-to -end testing. (For definition and more information on the different&lt;br /&gt;
kinds of testing, refer to[[http://en.wikipedia.org/wiki/Unit_testing ''' APPENDIX 3''']], [[http://en.wikipedia.org/wiki/Integration_testing ''' APPENDIX 4''']] )&lt;br /&gt;
&lt;br /&gt;
To write a TestNG test, we need to:&lt;br /&gt;
Write the business logic of the test, and insert the TestNG annotations in&lt;br /&gt;
them.&lt;br /&gt;
Add the information about our test (such as the class name, the groups we&lt;br /&gt;
wish to run, etc) in a testing.xml file or in build.xml.&lt;br /&gt;
Run the test.&lt;br /&gt;
TestNG supports data driven testing.(Data-driven testing is a methodology&lt;br /&gt;
used in Test automation where test scripts are executed and verified based&lt;br /&gt;
on the data values stored in one or more central data sources or databases.&lt;br /&gt;
For a detailed description on data driven testing click here:&lt;br /&gt;
http://en.wikipedia.org/wiki/Data-driven_testing  )&lt;br /&gt;
&lt;br /&gt;
TestNG is invoked in several different ways:&lt;br /&gt;
With a testing.xml file&lt;br /&gt;
ANT&lt;br /&gt;
Command line&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is possible to group the test methods of TestNG.  We can declare methods&lt;br /&gt;
that belong to these groups and specify groups that contain other groups. It&lt;br /&gt;
is very flexible as it can help in choosing one set of regular expression&lt;br /&gt;
and excluding the other sets. This splits the various test groups and there&lt;br /&gt;
is no need to recompile again if we want to run two different tests back to&lt;br /&gt;
back.&lt;br /&gt;
&lt;br /&gt;
Requirements:&lt;br /&gt;
JDK 1.4, 1.5&lt;br /&gt;
Invoked in many environments such as command line, ant, ECLIPSE, IDEA,&lt;br /&gt;
MAVEN, etc&lt;br /&gt;
&lt;br /&gt;
The annotations available in TestNG can be found at:&lt;br /&gt;
http://testng.org/doc/documentation-main.html#annotations&lt;br /&gt;
&lt;br /&gt;
TestNG is inspired from JUnit and Nunit, with additional functionalities&lt;br /&gt;
such as Flexible test configuration, support for data driven testing, etc.[[http://testng.org/doc/documentation-main.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Cactus ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Cactus is a test framework for testing server-side java code such as&lt;br /&gt;
Servlets, EJB, etc. It extends J Unit.&lt;br /&gt;
Cactus implements an in-container strategy which means that tests are&lt;br /&gt;
executed inside the container.&lt;br /&gt;
The Cactus testing unit can be viewed as a system that consists of the&lt;br /&gt;
following components:&lt;br /&gt;
&lt;br /&gt;
--Cactus Framework:  This provides the API to write Cactus tests.&lt;br /&gt;
&lt;br /&gt;
--Cactus Integration Modules: They are front ends and frameworks that&lt;br /&gt;
provide easy ways of using the Cactus Framework. Eg: Eclipse plugin&lt;br /&gt;
&lt;br /&gt;
--Cactus Samples: They demonstrate how to write Cactus tests and how to use&lt;br /&gt;
a few Integration Modules. [[http://jakarta.apache.org/cactus/index.html 2]]&lt;br /&gt;
&lt;br /&gt;
A useful testing framework provided by Cactus is  integration unit testing.&lt;br /&gt;
 The tests written for this framework will exercise the interactions with&lt;br /&gt;
the container. Cactus also provides other frameworks such as code logic unit&lt;br /&gt;
testing, functional unit testing.&lt;br /&gt;
&lt;br /&gt;
Cactus was developed to fit only integration unit testing with the idea that&lt;br /&gt;
it is much easier to have to write tests for a single framework than for&lt;br /&gt;
several. It is believed that Cactus provides a middle ground that provides a&lt;br /&gt;
high confidence that your code will run when deployed .[[http://jakarta.apache.org/cactus/index.html 2]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To know how it works, click here :&lt;br /&gt;
http://jakarta.apache.org/cactus/how_it_works.html&lt;br /&gt;
&lt;br /&gt;
=='''COMPARISON BETWEEN JUnit,TestNG and Cactus frameworks''' [[http://junit.sourceforge.net/doc/cookbook/cookbook.htm 3]]==&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''JUnit4'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''TestNG'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Cactus'''&lt;br /&gt;
|-&lt;br /&gt;
| Supporting Type of Testing||Suitable more for Unit testing||Supports Unit&lt;br /&gt;
testing,Functional testing, end-to-end testing, integration testing&lt;br /&gt;
||Primarily unit testing. Also have frameworks for code logic unit testing ,&lt;br /&gt;
functional logic unit testing&lt;br /&gt;
|-&lt;br /&gt;
| Conventions||Rigid  ||Flexible||Not as flexible as TestNG&lt;br /&gt;
|-&lt;br /&gt;
| Derived from JUnit||Yes, from the previous versions||Inspired from&lt;br /&gt;
Junit,with  added functionalities ||Extends JUnit&lt;br /&gt;
|-&lt;br /&gt;
| Flexibility for large suites||Not flexible for large test suites,&lt;br /&gt;
||Flexible for running large test suites of code  and thus one test\'s&lt;br /&gt;
failure shouldn\'t mean having to rerun a suite of thousands. || No, it is&lt;br /&gt;
suitable for unit testing.&lt;br /&gt;
|-&lt;br /&gt;
| Suitable for ||Best for a single object||Best for a higher level&lt;br /&gt;
testing||Best for server-side java code such as Servlets, EJB, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Works with||Command line, ANT,ECLIPSE||Command line,ANT, ECLIPSE,&lt;br /&gt;
IDEA,MAVEN||ANT&lt;br /&gt;
|-&lt;br /&gt;
| ||||||&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== An example comparing JUNIT 4 and TestNG ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''JUnit 4  v/s TestNG'''&lt;br /&gt;
&lt;br /&gt;
(source: http://www.ibm.com/developerworks/java/library/j-cq08296/)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The frameworks differ is in their core design. JUnit has always been an&lt;br /&gt;
effective unit-testing framework, meaning that it was built to facilitate&lt;br /&gt;
testing single objects. TestNG, on the other hand, was built to address&lt;br /&gt;
testing at higher levels, and consequently, has some features not available&lt;br /&gt;
in JUnit&lt;br /&gt;
&lt;br /&gt;
JUnit 4 makes clever use of annotations. JUnit no longer requires you to&lt;br /&gt;
define a test as a method whose name starts with test, and we can now run&lt;br /&gt;
fixtures just once as opposed to for each test.  However TestNG established&lt;br /&gt;
itself as an annotations-based framework long before Junit 4. TestNG&lt;br /&gt;
pioneered testing with annotations in Java programming, which made it a&lt;br /&gt;
formidable alternative to JUnit. [[http://www.ibm.com/developerworks/java/library/j-cq08296 4]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Sample J Unit 4 code&lt;br /&gt;
&lt;br /&gt;
 package test.com.acme.dona.dep;&lt;br /&gt;
 import static org.junit.Assert.assertEquals;&lt;br /&gt;
 import static org.junit.Assert.assertNotNull;&lt;br /&gt;
 import org.junit.BeforeClass;&lt;br /&gt;
 import org.junit.Test;&lt;br /&gt;
 public class DependencyFinderTest {&lt;br /&gt;
 private static DependencyFinder finder;&lt;br /&gt;
 @BeforeClass&lt;br /&gt;
 public static void init() throws Exception {&lt;br /&gt;
  finder = new DependencyFinder();&lt;br /&gt;
 }&lt;br /&gt;
 @Test&lt;br /&gt;
 public void verifyDependencies()&lt;br /&gt;
  throws Exception {&lt;br /&gt;
   String targetClss =&lt;br /&gt;
     &amp;quot;test.com.acme.dona.dep.DependencyFind&amp;quot;;&lt;br /&gt;
 Filter[] filtr = new Filter[] {&lt;br /&gt;
      new RegexPackageFilter(&amp;quot;java|junit|org&amp;quot;)};&lt;br /&gt;
 Dependency[] deps =&lt;br /&gt;
      finder.findDependencies(targetClss, filtr);&lt;br /&gt;
 assertNotNull(&amp;quot;deps was null&amp;quot;, deps);&lt;br /&gt;
   assertEquals(&amp;quot;should be 5 large&amp;quot;, 5, deps.length);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
 (source: http://www.ibm.com/developerworks/java/library/j-cq08296/)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Sample TestNG code&lt;br /&gt;
&lt;br /&gt;
 package test.com.acme.dona.dep;&lt;br /&gt;
 import static org.testng.Assert.assertEquals;&lt;br /&gt;
 import static org.testng.Assert.assertNotNull;&lt;br /&gt;
 import org.testng.annotations.BeforeClass;&lt;br /&gt;
 import org.testng.annotations.Configuration;&lt;br /&gt;
 import org.testng.annotations.Test;&lt;br /&gt;
 public class DependencyFinderTest {&lt;br /&gt;
 private DependencyFinder finder;&lt;br /&gt;
 @BeforeClass&lt;br /&gt;
 private void init(){&lt;br /&gt;
  this.finder = new DependencyFinder();&lt;br /&gt;
 }&lt;br /&gt;
 @Test&lt;br /&gt;
 public void verifyDependencies()&lt;br /&gt;
  throws Exception {&lt;br /&gt;
   String targetClss =&lt;br /&gt;
     &amp;quot;test.com.acme.dona.dep.DependencyFind&amp;quot;;&lt;br /&gt;
   Filter[] filtr = new Filter[] {&lt;br /&gt;
      new RegexPackageFilter(&amp;quot;java|junit|org&amp;quot;)};&lt;br /&gt;
   Dependency[] deps =&lt;br /&gt;
      finder.findDependencies(targetClss, filtr);&lt;br /&gt;
   assertNotNull(deps, &amp;quot;deps was null&amp;quot; );&lt;br /&gt;
   assertEquals(5, deps.length, &amp;quot;should be 5 large&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
 (source: http://www.ibm.com/developerworks/java/library/j-cq08296/)&lt;br /&gt;
&lt;br /&gt;
Both the codes may look a lot similar. However TestNG coding conventions are&lt;br /&gt;
more flexible than JUnit 4.&lt;br /&gt;
&lt;br /&gt;
JUnit forces us to declare the @BeforeClass (See [[http://junit.sourceforge.net/javadoc_40/org/junit/BeforeClass.html '''APPENDIX 5''']] for more&lt;br /&gt;
information)  method as static, which consequently requires us to also&lt;br /&gt;
declare the fixture, finder, as static. We also have to declare the init()&lt;br /&gt;
method as public. Looking at the TestNG code, you can find that such&lt;br /&gt;
conventions aren't required. Its init() method is neither static nor&lt;br /&gt;
public.&lt;br /&gt;
Flexibility has been one of the strong points of TestNG right from the&lt;br /&gt;
start. JUnit works well for a unit of code, whereas TestNG is better suited&lt;br /&gt;
for high-level testing. Its flexibility is especially useful with large test&lt;br /&gt;
suites.[[http://www.ibm.com/developerworks/java/library/j-cq08296 4]]&lt;br /&gt;
&lt;br /&gt;
== Some other JAVA testing units [[&lt;br /&gt;
http://www.opensourcetesting.org/unit_java.php 5]]  ==&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''JEasyTest'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''J2ME Unit Testing Toolkit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Jailer'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Mockrunner'''&lt;br /&gt;
|-&lt;br /&gt;
| Features||Generates coverage report Allows virtual mock object||Is a  Java&lt;br /&gt;
2 Micro Edition (J2ME) library containing a unit testing framework for&lt;br /&gt;
J2ME||Does test data exporting.  JDBC agnostic  Generates DbUnit datasets,&lt;br /&gt;
hierarchically structured XML, and topologically sorted SQL-DML.||A&lt;br /&gt;
lightweight framework for unit testing applications in the J2EE environment.&lt;br /&gt;
|-&lt;br /&gt;
| Integrates with:||ECLIPSE 3.3||ANT ||Platform Independent||OS independent&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Testing frameworks for C++   =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When it comes to unit testing in Java, a unanimous choice would be JUnit.&lt;br /&gt;
However for C++, there is no one clear winner.  CppUnit is the most widely&lt;br /&gt;
used tool for C++ which is a part of the XUnit family.&lt;br /&gt;
&lt;br /&gt;
Following is a few basic factors to judge a good testing unit in C++ [[&lt;br /&gt;
http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle6]]&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Features'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''CppUnit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''BOOST.test'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''CxxUnit'''&lt;br /&gt;
|-&lt;br /&gt;
| Minimal amount of work needed to add new tests ||No, and thus a major&lt;br /&gt;
downfall.||Yes||Yes, very good.&lt;br /&gt;
|-&lt;br /&gt;
| Easy to modify and port ||Medium||Medium||Simplest&lt;br /&gt;
|-&lt;br /&gt;
| Supports setup/teardown steps ||Yes||||Best&lt;br /&gt;
|-&lt;br /&gt;
| Handles exceptions and crashes well.||Yes||Yes, above others||Great&lt;br /&gt;
support.&lt;br /&gt;
|-&lt;br /&gt;
| Good assert functionality.||Pretty decent.||Yes||Best&lt;br /&gt;
|-&lt;br /&gt;
| Supports different outputs. ||Yes. Comes with IDE friendly&lt;br /&gt;
output.||Probably, Not trivial to change.||Yes&lt;br /&gt;
|-&lt;br /&gt;
| Supports  suites||Yes.||Yes, but with a big catch. ||Yes&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CppUnit passes most of the above tests , except for the first point and thus&lt;br /&gt;
needs a lot of code typing.&lt;br /&gt;
Boost.Test isn’t exclusively a unit-testing framework, and is not X Unit&lt;br /&gt;
based.&lt;br /&gt;
&lt;br /&gt;
Out of the above three , cxxUnit turns out to be a favourite.&lt;br /&gt;
&lt;br /&gt;
It comes close to the requirements of an ideal framework by leveraging the&lt;br /&gt;
power of an external scripting language. It provides some nifty advanced&lt;br /&gt;
features and great assert functionality. It does require the use of a&lt;br /&gt;
scripting language as part of the build process, so those uncomfortable with&lt;br /&gt;
that requirement, might want to look at one of the other two frameworks.&lt;br /&gt;
&lt;br /&gt;
For work restricted to the PC,  where modifying the framework is not&lt;br /&gt;
required Boost.Test could  be a very good choice.&lt;br /&gt;
CppUnit , which has come a long way in years is a solid, complete framework&lt;br /&gt;
 The major drawbacks are the relative verbosity for adding new tests and&lt;br /&gt;
fixtures. [[&lt;br /&gt;
http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle 6]]&lt;br /&gt;
&lt;br /&gt;
= Python =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Doctest''': It is a simple, ingenuine technology that allows you to write&lt;br /&gt;
a narrative in a document which can directly be executed as a test. It is&lt;br /&gt;
included in Python as a module.&lt;br /&gt;
&lt;br /&gt;
Although doctest makes testing code readable for non-programmers ,the&lt;br /&gt;
simplicity of a narrative test like doctest is accompanied by it’s own flaws&lt;br /&gt;
.Some of the disadvantages of using doctest are&lt;br /&gt;
&lt;br /&gt;
• These tests are difficult to handle in case of failures as they are more&lt;br /&gt;
generic. Specific tests are narrower and better in communicating intent and&lt;br /&gt;
ensuring coverage.&lt;br /&gt;
&lt;br /&gt;
• The test code is executed in a special way thus making it difficult to&lt;br /&gt;
reason about how it will be executed. It is also harder to program around&lt;br /&gt;
the tests.&lt;br /&gt;
&lt;br /&gt;
• It is actually difficult to get an outline of the tests at glance. There’s&lt;br /&gt;
no tool that can give an overview of the unit tests in a doc test file [[&lt;br /&gt;
http://en.wikipedia.org/wiki/Doctest 7]].&lt;br /&gt;
&lt;br /&gt;
An detailed information about doctest with thorough examples can be read at&lt;br /&gt;
http://docs.python.org/library/doctest.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Unittest''': Unittest are more specific tests which are more functional&lt;br /&gt;
in nature allowing it to be written for individual functions or the class as&lt;br /&gt;
a whole.&lt;br /&gt;
&lt;br /&gt;
The fact that Unittest is based on jUnit makes people with the xUnit&lt;br /&gt;
familiarity pick it up really quick hence it is more Java based than python&lt;br /&gt;
.It has been introduced in the Python’s library since version 2.1&lt;br /&gt;
&lt;br /&gt;
The disadvantages of using the unit test are&lt;br /&gt;
&lt;br /&gt;
• The tests have a different look and feel with respect to the code under&lt;br /&gt;
test&lt;br /&gt;
&lt;br /&gt;
• The assertions used in the text use custom syntax which makes it difficult&lt;br /&gt;
&lt;br /&gt;
• The test code is difficult to understand compared to the Doctest and the&lt;br /&gt;
strong basis on jUnit makes it difficult for the pure Python coders [[&lt;br /&gt;
http://en.wikipedia.org/wiki/Unit_testing 8]]&lt;br /&gt;
&lt;br /&gt;
A detailed information about doctest with thorough examples can be read at&lt;br /&gt;
http://docs.python.org/library/unittest.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Doctest vs Unittest'''&lt;br /&gt;
&lt;br /&gt;
Here we compare simple features of both the tests thus giving us an idea of&lt;br /&gt;
which one to use based on the requirement&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''doctest'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''unittest'''&lt;br /&gt;
|-&lt;br /&gt;
| '''Simplicity'''||Best suited for novice programmers||A little complex to&lt;br /&gt;
use specially if unaware of Junit&lt;br /&gt;
|-&lt;br /&gt;
| '''Documentation'''||Better Narratives||Tests have little or no comments&lt;br /&gt;
|-&lt;br /&gt;
| '''Comprehensive testing'''||Doctests get clutterd for comprehensive tests&lt;br /&gt;
and thus less readable||Best suited for comprehensive tests&lt;br /&gt;
|-&lt;br /&gt;
| '''Flexibility and Control'''||Less flexible||More flexible&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Ruby =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The basic testing framework for RUBY is xUnit . There are some frameworks&lt;br /&gt;
which have evolved over the years which include RSpec, Trantula, Flog,&lt;br /&gt;
RunCodeRun, Cucumber etc. We’ll talk about each of them in brief&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Testing Framework'''&lt;br /&gt;
| style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Description'''&lt;br /&gt;
|-&lt;br /&gt;
| '''Rspec[[http://www.elctech.com/tutorials/rspec-tutorial 9]]'''||It is&lt;br /&gt;
Behavior Driven Development whose basic features are&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Behavior counts first, testing follows&lt;br /&gt;
|-&lt;br /&gt;
| ||·         It focuses more on business values&lt;br /&gt;
|-&lt;br /&gt;
| ||·         It’s more about getting the words right rather than just&lt;br /&gt;
writing the test first&lt;br /&gt;
|-&lt;br /&gt;
| ||Advantages:&lt;br /&gt;
|-&lt;br /&gt;
| ||·         These are extremely easy to read and makes sense to a&lt;br /&gt;
non-programmer&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Rspec lets you unit test while also providing mocking and&lt;br /&gt;
stubbing support&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Rspec can help with the coverage tests using Rcov&lt;br /&gt;
|-&lt;br /&gt;
| ||·         One can also perform integration test using Rspec&lt;br /&gt;
|-&lt;br /&gt;
| ||Disadvantages:&lt;br /&gt;
|-&lt;br /&gt;
| ||·         It involves a lot of behind the scene metaprogramming which&lt;br /&gt;
makes the tests very difficult to understand&lt;br /&gt;
|-&lt;br /&gt;
| ||A simple Rspec example can be read at http://rspec.info/&lt;br /&gt;
|-&lt;br /&gt;
| '''Cucumber[[http://www.rubyinside.com/cucumber-the-latest-in-ruby-testing-1342 10]]'''||Cucumber,&lt;br /&gt;
the latest addition to the Rspec family allows one to&lt;br /&gt;
execute documentation written in plain text(known as ‘stories’)&lt;br /&gt;
|-&lt;br /&gt;
| ||A very good example of writing a test in cucumber can be read at&lt;br /&gt;
http://cukes.info/&lt;br /&gt;
|-&lt;br /&gt;
| ||&lt;br /&gt;
|-&lt;br /&gt;
| '''Tarantula[[http://www.ruby-forum.com/topic/144083 11]]'''||Tarantula is&lt;br /&gt;
a Rail’s plugin that produces a detailed report describing the URL’s that it&lt;br /&gt;
has crawled across and the responses that it received from each one of them.&lt;br /&gt;
|-&lt;br /&gt;
| ||Tarantula\'s functionality somewhat overlaps with the on site testing,&lt;br /&gt;
particularly if you are practicing test-driven development (TDD). Tarantula&lt;br /&gt;
runs against your actual Web site thereby helping you to identify the&lt;br /&gt;
problems associated with your production server, user-generated data, and&lt;br /&gt;
HTML compliance.&lt;br /&gt;
&lt;br /&gt;
A well explained example can be seen at&lt;br /&gt;
http://www.railslodge.com/plugins/959-tarantula&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| '''Flog[[http://www.brynary.com/2007/9/13/scourging-your-ruby-code-with-flog 12]]'''||Flog&lt;br /&gt;
is a tool which gives you a profile of your code’s complexity.&lt;br /&gt;
It can given the complexity pertaining to each method in your code. One can&lt;br /&gt;
also set threshold for each method using flog&lt;br /&gt;
|-&lt;br /&gt;
| ||The complexity of a code can be important to&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Find the bugs as they are highly probable in complex code&lt;br /&gt;
areas&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Complex codes can be considered for refactoring&lt;br /&gt;
|-&lt;br /&gt;
| ||A flog report has been explained and shown here&lt;br /&gt;
http://www.ruby-forum.com/topic/131931&lt;br /&gt;
|-&lt;br /&gt;
| ||&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= C# =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The list of frameworks that apply for .NET are applied for C#. A long list&lt;br /&gt;
of testing frameworks are available for C# which are NUnit, csUnit, Pex, dotunit,&lt;br /&gt;
VSNUnit, Nester[[http://csharp-source.net/open-source/testing-tools 13]].&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Nunit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''csUnit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''PEX'''&lt;br /&gt;
|-&lt;br /&gt;
| Description||NUnit has been ported from JUnit and has been written completely to take adavntage of the .NET languages.   It is a free open source unit testing tool for all the test-driven development .NET languages including C#.||The major advancements with NUnit are parameterized tests which provides a concise method to express a set of examples that can used to run individual test cases. It has been inspired from JUnit and can be used as an add-in along with the NUnit&lt;br /&gt;
&lt;br /&gt;
||It is a tool to generate efficient unit tests with a high code coverage and are converted to C# automatically. It determines the relevant test inputs for the code hunting for boundary conditions, exceptions and assertion failures. Pex enables Parameterized Unit Testing, an extension of Unit Testing that reduces test maintenance costs. &lt;br /&gt;
|-&lt;br /&gt;
| Examples||http://www.nunit.org/blogs/||http://www.csunit.org/tutorials/tutorial7/||http://research.microsoft.com/en-us/um/redmond/projects/pex/wiki/The%20Hello%20World%20of%20Pex.html&lt;br /&gt;
|-&lt;br /&gt;
| Used as ||Testing framework, GUI and console tool||Testing Framework ,Console tool and VS.NET Add In||It supports NUnit, MbUnit and xUnit.net.Extensions for these test frameworks can be downloaded from the Pex Extensions Project.&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=APPENDIX=&lt;br /&gt;
&lt;br /&gt;
'''JUnit''' - JUnit is a unit testing framework for the Java programming&lt;br /&gt;
language. JUnit has been important in the development of test-driven&lt;br /&gt;
development, and comprises a family of unit testing frameworks collectively&lt;br /&gt;
known as xUnit that originated with SUnit. (For more information refer to&lt;br /&gt;
http://www.junit.org,http://en.wikipedia.org/wiki/Junit)&lt;br /&gt;
&lt;br /&gt;
'''XUnit''' - Various code-driven testing frameworks have come to be known&lt;br /&gt;
collectively as xUnit. These frameworks allow testing of different elements&lt;br /&gt;
(units) of software, such as functions and classes. (For more information&lt;br /&gt;
refer to http://en.wikipedia.org/wiki/XUnit)&lt;br /&gt;
&lt;br /&gt;
'''unit testing''' - unit testing is a software verification and validation&lt;br /&gt;
method in which a programmer tests if individual units of source code are&lt;br /&gt;
fit for use, where a unit is the smallest testable part of an application.&lt;br /&gt;
For more information refer http://en.wikipedia.org/wiki/Unit_testing&lt;br /&gt;
&lt;br /&gt;
'''integration testing''' - is the activity of software testing in which&lt;br /&gt;
individual software modules are combined and tested as a group. It occurs&lt;br /&gt;
after unit testing. For more information refer&lt;br /&gt;
http://en.wikipedia.org/wiki/Integration_testing&lt;br /&gt;
&lt;br /&gt;
'''BeforeClass''' - Refer to&lt;br /&gt;
http://junit.sourceforge.net/javadoc_40/org/junit/BeforeClass.html&lt;br /&gt;
&lt;br /&gt;
'''parameterized testing''' - . A parameterized unit test is simply a method that takes parameters, calls the code under test, and states assertions.&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[1]  http://testng.org/doc/documentation-main.html&lt;br /&gt;
&lt;br /&gt;
[2]  http://jakarta.apache.org/cactus/index.html&lt;br /&gt;
&lt;br /&gt;
[3]  http://junit.sourceforge.net/doc/cookbook/cookbook.htm&lt;br /&gt;
&lt;br /&gt;
[4]  http://www.ibm.com/developerworks/java/library/j-cq08296&lt;br /&gt;
&lt;br /&gt;
[5]  http://www.opensourcetesting.org/unit_java.php&lt;br /&gt;
&lt;br /&gt;
[6]&lt;br /&gt;
http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle&lt;br /&gt;
&lt;br /&gt;
[7] http://en.wikipedia.org/wiki/Doctest&lt;br /&gt;
&lt;br /&gt;
[8] http://en.wikipedia.org/wiki/Unit_testing&lt;br /&gt;
&lt;br /&gt;
[9] http://www.elctech.com/tutorials/rspec-tutorial&lt;br /&gt;
&lt;br /&gt;
[10] http://www.rubyinside.com/cucumber-the-latest-in-ruby-testing-1342.html&lt;br /&gt;
&lt;br /&gt;
[11] http://www.ruby-forum.com/topic/144083&lt;br /&gt;
&lt;br /&gt;
[12] http://www.brynary.com/2007/9/13/scourging-your-ruby-code-with-flog&lt;br /&gt;
&lt;br /&gt;
[13] http://csharp-source.net/open-source/testing-tools&lt;br /&gt;
&lt;br /&gt;
[14] http://research.microsoft.com/en-us/um/redmond/projects/pex/wiki/reference%20manual.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b12_AV&amp;diff=22401</id>
		<title>CSC/ECE 517 Fall 2009/wiki1b12 AV</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b12_AV&amp;diff=22401"/>
		<updated>2009-09-29T03:01:25Z</updated>

		<summary type="html">&lt;p&gt;Vdiyer: /* An example comparing JUNIT 4 and TestNG */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;XUnit in general, is only one kind of testing framework for object oriented&lt;br /&gt;
languages. This page talks about the major testing frameworks available for&lt;br /&gt;
the major object oriented languages such as Java, C++, C#,Python, Ruby and&lt;br /&gt;
C#. Comparisons have been made wherever possible between the major&lt;br /&gt;
frameworks available in each language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Java Testing Frameworks =&lt;br /&gt;
&lt;br /&gt;
Plenty of testing framework exist for Java. JUnit has been the de facto&lt;br /&gt;
standard for unit testing. However, other frameworks such as TestNG, JTIGER&lt;br /&gt;
have been built to address various faults and deficiencies with JUnit.  Our&lt;br /&gt;
primary objective is to compare the various testing frameworks that exist&lt;br /&gt;
for object oriented languages based on the primary purpose of the framework,&lt;br /&gt;
features, the platforms on which they operate, etc and thus help in picking&lt;br /&gt;
up the best testing framework that fits in a particular suitable&lt;br /&gt;
environment.&lt;br /&gt;
This article DOES NOT introduce JUnit or XUnit. For information on JUnit,&lt;br /&gt;
please refer to http://www.junit.org or [[http://en.wikipedia.org/wiki/Junit '''APPENDIX 1''']]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== TestNG Framework ==&lt;br /&gt;
&lt;br /&gt;
TestNG is a testing framework which can help to meet a broad range of&lt;br /&gt;
testing such as unit testing, integration testing, functional testing,&lt;br /&gt;
end-to -end testing. (For definition and more information on the different&lt;br /&gt;
kinds of testing, refer to[[http://en.wikipedia.org/wiki/Unit_testing ''' APPENDIX 3''']], [[http://en.wikipedia.org/wiki/Integration_testing ''' APPENDIX 4''']] )&lt;br /&gt;
&lt;br /&gt;
To write a TestNG test, we need to:&lt;br /&gt;
Write the business logic of the test, and insert the TestNG annotations in&lt;br /&gt;
them.&lt;br /&gt;
Add the information about our test (such as the class name, the groups we&lt;br /&gt;
wish to run, etc) in a testing.xml file or in build.xml.&lt;br /&gt;
Run the test.&lt;br /&gt;
TestNG supports data driven testing.(Data-driven testing is a methodology&lt;br /&gt;
used in Test automation where test scripts are executed and verified based&lt;br /&gt;
on the data values stored in one or more central data sources or databases.&lt;br /&gt;
For a detailed description on data driven testing click here:&lt;br /&gt;
http://en.wikipedia.org/wiki/Data-driven_testing  )&lt;br /&gt;
&lt;br /&gt;
TestNG is invoked in several different ways:&lt;br /&gt;
With a testing.xml file&lt;br /&gt;
ANT&lt;br /&gt;
Command line&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is possible to group the test methods of TestNG.  We can declare methods&lt;br /&gt;
that belong to these groups and specify groups that contain other groups. It&lt;br /&gt;
is very flexible as it can help in choosing one set of regular expression&lt;br /&gt;
and excluding the other sets. This splits the various test groups and there&lt;br /&gt;
is no need to recompile again if we want to run two different tests back to&lt;br /&gt;
back.&lt;br /&gt;
&lt;br /&gt;
Requirements:&lt;br /&gt;
JDK 1.4, 1.5&lt;br /&gt;
Invoked in many environments such as command line, ant, ECLIPSE, IDEA,&lt;br /&gt;
MAVEN, etc&lt;br /&gt;
&lt;br /&gt;
The annotations available in TestNG can be found at:&lt;br /&gt;
http://testng.org/doc/documentation-main.html#annotations&lt;br /&gt;
&lt;br /&gt;
TestNG is inspired from JUnit and Nunit, with additional functionalities&lt;br /&gt;
such as Flexible test configuration, support for data driven testing, etc.[[http://testng.org/doc/documentation-main.html 1]]&lt;br /&gt;
&lt;br /&gt;
== Cactus ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Cactus is a test framework for testing server-side java code such as&lt;br /&gt;
Servlets, EJB, etc. It extends J Unit.&lt;br /&gt;
Cactus implements an in-container strategy which means that tests are&lt;br /&gt;
executed inside the container.&lt;br /&gt;
The Cactus testing unit can be viewed as a system that consists of the&lt;br /&gt;
following components:&lt;br /&gt;
&lt;br /&gt;
--Cactus Framework:  This provides the API to write Cactus tests.&lt;br /&gt;
&lt;br /&gt;
--Cactus Integration Modules: They are front ends and frameworks that&lt;br /&gt;
provide easy ways of using the Cactus Framework. Eg: Eclipse plugin&lt;br /&gt;
&lt;br /&gt;
--Cactus Samples: They demonstrate how to write Cactus tests and how to use&lt;br /&gt;
a few Integration Modules. [[http://jakarta.apache.org/cactus/index.html 2]]&lt;br /&gt;
&lt;br /&gt;
A useful testing framework provided by Cactus is  integration unit testing.&lt;br /&gt;
 The tests written for this framework will exercise the interactions with&lt;br /&gt;
the container. Cactus also provides other frameworks such as code logic unit&lt;br /&gt;
testing, functional unit testing.&lt;br /&gt;
&lt;br /&gt;
Cactus was developed to fit only integration unit testing with the idea that&lt;br /&gt;
it is much easier to have to write tests for a single framework than for&lt;br /&gt;
several. It is believed that Cactus provides a middle ground that provides a&lt;br /&gt;
high confidence that your code will run when deployed .[[&lt;br /&gt;
http://jakarta.apache.org/cactus/index.html 2]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To know how it works, click here :&lt;br /&gt;
http://jakarta.apache.org/cactus/how_it_works.html&lt;br /&gt;
&lt;br /&gt;
== '''COMPARISON BETWEEN JUnit,TestNG and Cactus frameworks''' [[&lt;br /&gt;
http://junit.sourceforge.net/doc/cookbook/cookbook.htm 3]] ==&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''JUnit4'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''TestNG'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Cactus'''&lt;br /&gt;
|-&lt;br /&gt;
| Supporting Type of Testing||Suitable more for Unit testing||Supports Unit&lt;br /&gt;
testing,Functional testing, end-to-end testing, integration testing&lt;br /&gt;
||Primarily unit testing. Also have frameworks for code logic unit testing ,&lt;br /&gt;
functional logic unit testing&lt;br /&gt;
|-&lt;br /&gt;
| Conventions||Rigid  ||Flexible||Not as flexible as TestNG&lt;br /&gt;
|-&lt;br /&gt;
| Derived from JUnit||Yes, from the previous versions||Inspired from&lt;br /&gt;
Junit,with  added functionalities ||Extends JUnit&lt;br /&gt;
|-&lt;br /&gt;
| Flexibility for large suites||Not flexible for large test suites,&lt;br /&gt;
||Flexible for running large test suites of code  and thus one test\'s&lt;br /&gt;
failure shouldn\'t mean having to rerun a suite of thousands. || No, it is&lt;br /&gt;
suitable for unit testing.&lt;br /&gt;
|-&lt;br /&gt;
| Suitable for ||Best for a single object||Best for a higher level&lt;br /&gt;
testing||Best for server-side java code such as Servlets, EJB, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Works with||Command line, ANT,ECLIPSE||Command line,ANT, ECLIPSE,&lt;br /&gt;
IDEA,MAVEN||ANT&lt;br /&gt;
|-&lt;br /&gt;
| ||||||&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== An example comparing JUNIT 4 and TestNG ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''JUnit 4  v/s TestNG'''&lt;br /&gt;
&lt;br /&gt;
(source: http://www.ibm.com/developerworks/java/library/j-cq08296/)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The frameworks differ is in their core design. JUnit has always been an&lt;br /&gt;
effective unit-testing framework, meaning that it was built to facilitate&lt;br /&gt;
testing single objects. TestNG, on the other hand, was built to address&lt;br /&gt;
testing at higher levels, and consequently, has some features not available&lt;br /&gt;
in JUnit&lt;br /&gt;
&lt;br /&gt;
JUnit 4 makes clever use of annotations. JUnit no longer requires you to&lt;br /&gt;
define a test as a method whose name starts with test, and we can now run&lt;br /&gt;
fixtures just once as opposed to for each test.  However TestNG established&lt;br /&gt;
itself as an annotations-based framework long before Junit 4. TestNG&lt;br /&gt;
pioneered testing with annotations in Java programming, which made it a&lt;br /&gt;
formidable alternative to JUnit. [[http://www.ibm.com/developerworks/java/library/j-cq08296 4]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Sample J Unit 4 code&lt;br /&gt;
&lt;br /&gt;
 package test.com.acme.dona.dep;&lt;br /&gt;
 import static org.junit.Assert.assertEquals;&lt;br /&gt;
 import static org.junit.Assert.assertNotNull;&lt;br /&gt;
 import org.junit.BeforeClass;&lt;br /&gt;
 import org.junit.Test;&lt;br /&gt;
 public class DependencyFinderTest {&lt;br /&gt;
 private static DependencyFinder finder;&lt;br /&gt;
 @BeforeClass&lt;br /&gt;
 public static void init() throws Exception {&lt;br /&gt;
  finder = new DependencyFinder();&lt;br /&gt;
 }&lt;br /&gt;
 @Test&lt;br /&gt;
 public void verifyDependencies()&lt;br /&gt;
  throws Exception {&lt;br /&gt;
   String targetClss =&lt;br /&gt;
     &amp;quot;test.com.acme.dona.dep.DependencyFind&amp;quot;;&lt;br /&gt;
 Filter[] filtr = new Filter[] {&lt;br /&gt;
      new RegexPackageFilter(&amp;quot;java|junit|org&amp;quot;)};&lt;br /&gt;
 Dependency[] deps =&lt;br /&gt;
      finder.findDependencies(targetClss, filtr);&lt;br /&gt;
 assertNotNull(&amp;quot;deps was null&amp;quot;, deps);&lt;br /&gt;
   assertEquals(&amp;quot;should be 5 large&amp;quot;, 5, deps.length);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
 (source: http://www.ibm.com/developerworks/java/library/j-cq08296/)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Sample TestNG code&lt;br /&gt;
&lt;br /&gt;
 package test.com.acme.dona.dep;&lt;br /&gt;
 import static org.testng.Assert.assertEquals;&lt;br /&gt;
 import static org.testng.Assert.assertNotNull;&lt;br /&gt;
 import org.testng.annotations.BeforeClass;&lt;br /&gt;
 import org.testng.annotations.Configuration;&lt;br /&gt;
 import org.testng.annotations.Test;&lt;br /&gt;
 public class DependencyFinderTest {&lt;br /&gt;
 private DependencyFinder finder;&lt;br /&gt;
 @BeforeClass&lt;br /&gt;
 private void init(){&lt;br /&gt;
  this.finder = new DependencyFinder();&lt;br /&gt;
 }&lt;br /&gt;
 @Test&lt;br /&gt;
 public void verifyDependencies()&lt;br /&gt;
  throws Exception {&lt;br /&gt;
   String targetClss =&lt;br /&gt;
     &amp;quot;test.com.acme.dona.dep.DependencyFind&amp;quot;;&lt;br /&gt;
   Filter[] filtr = new Filter[] {&lt;br /&gt;
      new RegexPackageFilter(&amp;quot;java|junit|org&amp;quot;)};&lt;br /&gt;
   Dependency[] deps =&lt;br /&gt;
      finder.findDependencies(targetClss, filtr);&lt;br /&gt;
   assertNotNull(deps, &amp;quot;deps was null&amp;quot; );&lt;br /&gt;
   assertEquals(5, deps.length, &amp;quot;should be 5 large&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
 (source: http://www.ibm.com/developerworks/java/library/j-cq08296/)&lt;br /&gt;
&lt;br /&gt;
Both the codes may look a lot similar. However TestNG coding conventions are&lt;br /&gt;
more flexible than JUnit 4.&lt;br /&gt;
&lt;br /&gt;
JUnit forces us to declare the @BeforeClass (See [[http://junit.sourceforge.net/javadoc_40/org/junit/BeforeClass.html '''APPENDIX 5''']] for more&lt;br /&gt;
information)  method as static, which consequently requires us to also&lt;br /&gt;
declare the fixture, finder, as static. We also have to declare the init()&lt;br /&gt;
method as public. Looking at the TestNG code, you can find that such&lt;br /&gt;
conventions aren't required. Its init() method is neither static nor&lt;br /&gt;
public.&lt;br /&gt;
Flexibility has been one of the strong points of TestNG right from the&lt;br /&gt;
start. JUnit works well for a unit of code, whereas TestNG is better suited&lt;br /&gt;
for high-level testing. Its flexibility is especially useful with large test&lt;br /&gt;
suites.[[http://www.ibm.com/developerworks/java/library/j-cq08296 4]]&lt;br /&gt;
&lt;br /&gt;
== Some other JAVA testing units [[&lt;br /&gt;
http://www.opensourcetesting.org/unit_java.php 5]]  ==&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''JEasyTest'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''J2ME Unit Testing Toolkit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Jailer'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Mockrunner'''&lt;br /&gt;
|-&lt;br /&gt;
| Features||Generates coverage report Allows virtual mock object||Is a  Java&lt;br /&gt;
2 Micro Edition (J2ME) library containing a unit testing framework for&lt;br /&gt;
J2ME||Does test data exporting.  JDBC agnostic  Generates DbUnit datasets,&lt;br /&gt;
hierarchically structured XML, and topologically sorted SQL-DML.||A&lt;br /&gt;
lightweight framework for unit testing applications in the J2EE environment.&lt;br /&gt;
|-&lt;br /&gt;
| Integrates with:||ECLIPSE 3.3||ANT ||Platform Independent||OS independent&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Testing frameworks for C++   =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When it comes to unit testing in Java, a unanimous choice would be JUnit.&lt;br /&gt;
However for C++, there is no one clear winner.  CppUnit is the most widely&lt;br /&gt;
used tool for C++ which is a part of the XUnit family.&lt;br /&gt;
&lt;br /&gt;
Following is a few basic factors to judge a good testing unit in C++ [[&lt;br /&gt;
http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle6]]&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Features'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''CppUnit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''BOOST.test'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''CxxUnit'''&lt;br /&gt;
|-&lt;br /&gt;
| Minimal amount of work needed to add new tests ||No, and thus a major&lt;br /&gt;
downfall.||Yes||Yes, very good.&lt;br /&gt;
|-&lt;br /&gt;
| Easy to modify and port ||Medium||Medium||Simplest&lt;br /&gt;
|-&lt;br /&gt;
| Supports setup/teardown steps ||Yes||||Best&lt;br /&gt;
|-&lt;br /&gt;
| Handles exceptions and crashes well.||Yes||Yes, above others||Great&lt;br /&gt;
support.&lt;br /&gt;
|-&lt;br /&gt;
| Good assert functionality.||Pretty decent.||Yes||Best&lt;br /&gt;
|-&lt;br /&gt;
| Supports different outputs. ||Yes. Comes with IDE friendly&lt;br /&gt;
output.||Probably, Not trivial to change.||Yes&lt;br /&gt;
|-&lt;br /&gt;
| Supports  suites||Yes.||Yes, but with a big catch. ||Yes&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CppUnit passes most of the above tests , except for the first point and thus&lt;br /&gt;
needs a lot of code typing.&lt;br /&gt;
Boost.Test isn’t exclusively a unit-testing framework, and is not X Unit&lt;br /&gt;
based.&lt;br /&gt;
&lt;br /&gt;
Out of the above three , cxxUnit turns out to be a favourite.&lt;br /&gt;
&lt;br /&gt;
It comes close to the requirements of an ideal framework by leveraging the&lt;br /&gt;
power of an external scripting language. It provides some nifty advanced&lt;br /&gt;
features and great assert functionality. It does require the use of a&lt;br /&gt;
scripting language as part of the build process, so those uncomfortable with&lt;br /&gt;
that requirement, might want to look at one of the other two frameworks.&lt;br /&gt;
&lt;br /&gt;
For work restricted to the PC,  where modifying the framework is not&lt;br /&gt;
required Boost.Test could  be a very good choice.&lt;br /&gt;
CppUnit , which has come a long way in years is a solid, complete framework&lt;br /&gt;
 The major drawbacks are the relative verbosity for adding new tests and&lt;br /&gt;
fixtures. [[&lt;br /&gt;
http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle 6]]&lt;br /&gt;
&lt;br /&gt;
= Python =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Doctest''': It is a simple, ingenuine technology that allows you to write&lt;br /&gt;
a narrative in a document which can directly be executed as a test. It is&lt;br /&gt;
included in Python as a module.&lt;br /&gt;
&lt;br /&gt;
Although doctest makes testing code readable for non-programmers ,the&lt;br /&gt;
simplicity of a narrative test like doctest is accompanied by it’s own flaws&lt;br /&gt;
.Some of the disadvantages of using doctest are&lt;br /&gt;
&lt;br /&gt;
• These tests are difficult to handle in case of failures as they are more&lt;br /&gt;
generic. Specific tests are narrower and better in communicating intent and&lt;br /&gt;
ensuring coverage.&lt;br /&gt;
&lt;br /&gt;
• The test code is executed in a special way thus making it difficult to&lt;br /&gt;
reason about how it will be executed. It is also harder to program around&lt;br /&gt;
the tests.&lt;br /&gt;
&lt;br /&gt;
• It is actually difficult to get an outline of the tests at glance. There’s&lt;br /&gt;
no tool that can give an overview of the unit tests in a doc test file [[&lt;br /&gt;
http://en.wikipedia.org/wiki/Doctest 7]].&lt;br /&gt;
&lt;br /&gt;
An detailed information about doctest with thorough examples can be read at&lt;br /&gt;
http://docs.python.org/library/doctest.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Unittest''': Unittest are more specific tests which are more functional&lt;br /&gt;
in nature allowing it to be written for individual functions or the class as&lt;br /&gt;
a whole.&lt;br /&gt;
&lt;br /&gt;
The fact that Unittest is based on jUnit makes people with the xUnit&lt;br /&gt;
familiarity pick it up really quick hence it is more Java based than python&lt;br /&gt;
.It has been introduced in the Python’s library since version 2.1&lt;br /&gt;
&lt;br /&gt;
The disadvantages of using the unit test are&lt;br /&gt;
&lt;br /&gt;
• The tests have a different look and feel with respect to the code under&lt;br /&gt;
test&lt;br /&gt;
&lt;br /&gt;
• The assertions used in the text use custom syntax which makes it difficult&lt;br /&gt;
&lt;br /&gt;
• The test code is difficult to understand compared to the Doctest and the&lt;br /&gt;
strong basis on jUnit makes it difficult for the pure Python coders [[&lt;br /&gt;
http://en.wikipedia.org/wiki/Unit_testing 8]]&lt;br /&gt;
&lt;br /&gt;
A detailed information about doctest with thorough examples can be read at&lt;br /&gt;
http://docs.python.org/library/unittest.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Doctest vs Unittest'''&lt;br /&gt;
&lt;br /&gt;
Here we compare simple features of both the tests thus giving us an idea of&lt;br /&gt;
which one to use based on the requirement&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''doctest'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''unittest'''&lt;br /&gt;
|-&lt;br /&gt;
| '''Simplicity'''||Best suited for novice programmers||A little complex to&lt;br /&gt;
use specially if unaware of Junit&lt;br /&gt;
|-&lt;br /&gt;
| '''Documentation'''||Better Narratives||Tests have little or no comments&lt;br /&gt;
|-&lt;br /&gt;
| '''Comprehensive testing'''||Doctests get clutterd for comprehensive tests&lt;br /&gt;
and thus less readable||Best suited for comprehensive tests&lt;br /&gt;
|-&lt;br /&gt;
| '''Flexibility and Control'''||Less flexible||More flexible&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Ruby =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The basic testing framework for RUBY is xUnit . There are some frameworks&lt;br /&gt;
which have evolved over the years which include RSpec, Trantula, Flog,&lt;br /&gt;
RunCodeRun, Cucumber etc. We’ll talk about each of them in brief&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Testing Framework'''&lt;br /&gt;
| style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Description'''&lt;br /&gt;
|-&lt;br /&gt;
| '''Rspec[[http://www.elctech.com/tutorials/rspec-tutorial 9]]'''||It is&lt;br /&gt;
Behavior Driven Development whose basic features are&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Behavior counts first, testing follows&lt;br /&gt;
|-&lt;br /&gt;
| ||·         It focuses more on business values&lt;br /&gt;
|-&lt;br /&gt;
| ||·         It’s more about getting the words right rather than just&lt;br /&gt;
writing the test first&lt;br /&gt;
|-&lt;br /&gt;
| ||Advantages:&lt;br /&gt;
|-&lt;br /&gt;
| ||·         These are extremely easy to read and makes sense to a&lt;br /&gt;
non-programmer&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Rspec lets you unit test while also providing mocking and&lt;br /&gt;
stubbing support&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Rspec can help with the coverage tests using Rcov&lt;br /&gt;
|-&lt;br /&gt;
| ||·         One can also perform integration test using Rspec&lt;br /&gt;
|-&lt;br /&gt;
| ||Disadvantages:&lt;br /&gt;
|-&lt;br /&gt;
| ||·         It involves a lot of behind the scene metaprogramming which&lt;br /&gt;
makes the tests very difficult to understand&lt;br /&gt;
|-&lt;br /&gt;
| ||A simple Rspec example can be read at http://rspec.info/&lt;br /&gt;
|-&lt;br /&gt;
| '''Cucumber[[http://www.rubyinside.com/cucumber-the-latest-in-ruby-testing-1342 10]]'''||Cucumber,&lt;br /&gt;
the latest addition to the Rspec family allows one to&lt;br /&gt;
execute documentation written in plain text(known as ‘stories’)&lt;br /&gt;
|-&lt;br /&gt;
| ||A very good example of writing a test in cucumber can be read at&lt;br /&gt;
http://cukes.info/&lt;br /&gt;
|-&lt;br /&gt;
| ||&lt;br /&gt;
|-&lt;br /&gt;
| '''Tarantula[[http://www.ruby-forum.com/topic/144083 11]]'''||Tarantula is&lt;br /&gt;
a Rail’s plugin that produces a detailed report describing the URL’s that it&lt;br /&gt;
has crawled across and the responses that it received from each one of them.&lt;br /&gt;
|-&lt;br /&gt;
| ||Tarantula\'s functionality somewhat overlaps with the on site testing,&lt;br /&gt;
particularly if you are practicing test-driven development (TDD). Tarantula&lt;br /&gt;
runs against your actual Web site thereby helping you to identify the&lt;br /&gt;
problems associated with your production server, user-generated data, and&lt;br /&gt;
HTML compliance.&lt;br /&gt;
&lt;br /&gt;
A well explained example can be seen at&lt;br /&gt;
http://www.railslodge.com/plugins/959-tarantula&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| '''Flog[[http://www.brynary.com/2007/9/13/scourging-your-ruby-code-with-flog 12]]'''||Flog&lt;br /&gt;
is a tool which gives you a profile of your code’s complexity.&lt;br /&gt;
It can given the complexity pertaining to each method in your code. One can&lt;br /&gt;
also set threshold for each method using flog&lt;br /&gt;
|-&lt;br /&gt;
| ||The complexity of a code can be important to&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Find the bugs as they are highly probable in complex code&lt;br /&gt;
areas&lt;br /&gt;
|-&lt;br /&gt;
| ||·         Complex codes can be considered for refactoring&lt;br /&gt;
|-&lt;br /&gt;
| ||A flog report has been explained and shown here&lt;br /&gt;
http://www.ruby-forum.com/topic/131931&lt;br /&gt;
|-&lt;br /&gt;
| ||&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= C# =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The list of frameworks that apply for .NET are applied for C#. A long list&lt;br /&gt;
of testing frameworks are available for C# which are NUnit, csUnit, Pex, dotunit,&lt;br /&gt;
VSNUnit, Nester[[http://csharp-source.net/open-source/testing-tools 13]].&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|''''''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Nunit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''csUnit'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''PEX'''&lt;br /&gt;
|-&lt;br /&gt;
| Description||NUnit has been ported from JUnit and has been written completely to take adavntage of the .NET languages.   It is a free open source unit testing tool for all the test-driven development .NET languages including C#.||The major advancements with NUnit are parameterized tests which provides a concise method to express a set of examples that can used to run individual test cases. It has been inspired from JUnit and can be used as an add-in along with the NUnit&lt;br /&gt;
&lt;br /&gt;
||It is a tool to generate efficient unit tests with a high code coverage and are converted to C# automatically. It determines the relevant test inputs for the code hunting for boundary conditions, exceptions and assertion failures. Pex enables Parameterized Unit Testing, an extension of Unit Testing that reduces test maintenance costs. &lt;br /&gt;
|-&lt;br /&gt;
| Examples||http://www.nunit.org/blogs/||http://www.csunit.org/tutorials/tutorial7/||http://research.microsoft.com/en-us/um/redmond/projects/pex/wiki/The%20Hello%20World%20of%20Pex.html&lt;br /&gt;
|-&lt;br /&gt;
| Used as ||Testing framework, GUI and console tool||Testing Framework ,Console tool and VS.NET Add In||It supports NUnit, MbUnit and xUnit.net.Extensions for these test frameworks can be downloaded from the Pex Extensions Project.&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=APPENDIX=&lt;br /&gt;
&lt;br /&gt;
'''JUnit''' - JUnit is a unit testing framework for the Java programming&lt;br /&gt;
language. JUnit has been important in the development of test-driven&lt;br /&gt;
development, and comprises a family of unit testing frameworks collectively&lt;br /&gt;
known as xUnit that originated with SUnit. (For more information refer to&lt;br /&gt;
http://www.junit.org,http://en.wikipedia.org/wiki/Junit)&lt;br /&gt;
&lt;br /&gt;
'''XUnit''' - Various code-driven testing frameworks have come to be known&lt;br /&gt;
collectively as xUnit. These frameworks allow testing of different elements&lt;br /&gt;
(units) of software, such as functions and classes. (For more information&lt;br /&gt;
refer to http://en.wikipedia.org/wiki/XUnit)&lt;br /&gt;
&lt;br /&gt;
'''unit testing''' - unit testing is a software verification and validation&lt;br /&gt;
method in which a programmer tests if individual units of source code are&lt;br /&gt;
fit for use, where a unit is the smallest testable part of an application.&lt;br /&gt;
For more information refer http://en.wikipedia.org/wiki/Unit_testing&lt;br /&gt;
&lt;br /&gt;
'''integration testing''' - is the activity of software testing in which&lt;br /&gt;
individual software modules are combined and tested as a group. It occurs&lt;br /&gt;
after unit testing. For more information refer&lt;br /&gt;
http://en.wikipedia.org/wiki/Integration_testing&lt;br /&gt;
&lt;br /&gt;
'''BeforeClass''' - Refer to&lt;br /&gt;
http://junit.sourceforge.net/javadoc_40/org/junit/BeforeClass.html&lt;br /&gt;
&lt;br /&gt;
'''parameterized testing''' - . A parameterized unit test is simply a method that takes parameters, calls the code under test, and states assertions.&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[1]  http://testng.org/doc/documentation-main.html&lt;br /&gt;
&lt;br /&gt;
[2]  http://jakarta.apache.org/cactus/index.html&lt;br /&gt;
&lt;br /&gt;
[3]  http://junit.sourceforge.net/doc/cookbook/cookbook.htm&lt;br /&gt;
&lt;br /&gt;
[4]  http://www.ibm.com/developerworks/java/library/j-cq08296&lt;br /&gt;
&lt;br /&gt;
[5]  http://www.opensourcetesting.org/unit_java.php&lt;br /&gt;
&lt;br /&gt;
[6]&lt;br /&gt;
http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle&lt;br /&gt;
&lt;br /&gt;
[7] http://en.wikipedia.org/wiki/Doctest&lt;br /&gt;
&lt;br /&gt;
[8] http://en.wikipedia.org/wiki/Unit_testing&lt;br /&gt;
&lt;br /&gt;
[9] http://www.elctech.com/tutorials/rspec-tutorial&lt;br /&gt;
&lt;br /&gt;
[10] http://www.rubyinside.com/cucumber-the-latest-in-ruby-testing-1342.html&lt;br /&gt;
&lt;br /&gt;
[11] http://www.ruby-forum.com/topic/144083&lt;br /&gt;
&lt;br /&gt;
[12] http://www.brynary.com/2007/9/13/scourging-your-ruby-code-with-flog&lt;br /&gt;
&lt;br /&gt;
[13] http://csharp-source.net/open-source/testing-tools&lt;br /&gt;
&lt;br /&gt;
[14] http://research.microsoft.com/en-us/um/redmond/projects/pex/wiki/reference%20manual.html&lt;/div&gt;</summary>
		<author><name>Vdiyer</name></author>
	</entry>
</feed>