Preparation
From this assignment on, we will be using Eclipse projects as available from 101repo.
One could pull or download 101repo in one piece:
https://github.com/101companies/101repo
Instead, one could also just download the specific .zip file for the starting point contribution; see link on wiki page.
Starting point
http://101companies.org/wiki/Contribution:aspectJ
Objective
Experiment with method execution advice and inter-type declarations, i.e., language concepts of aspect-oriented programming.
Task
There are two milestones.
Milestone 1 is to refactor the existing Contribution:aspectJ such that a visitor is used for the operations cut and total. (The operation depth can be removed or retained the way it is.) The important requirement is here though that the visitor is not readily placed in the relevant classes (Company, Department, Employee), but visitor support must be added by an inter-type declaration.
Milestone 2 is to add an aspect for message counting to the project. If we assume that Milestone has led to a visitor (class/interface) with one visit method each for Company, Department, and Employee, then we want an aspect with simply counts executions of these visit methods. To this end, a pointcut for method execution is to be used.
Hint
Milestone 1 can receive inspiration from the existing use of inter-type declarations in the project. Milestone 2 can receive inspiration from the logging aspect in the project.
Testing
Test cases for Feature:Total and Feature:Cut should remain intact as usual. An additional test case is needed to test on method-execution counting. To this end, counting should be performed for a computation of salary total. The expected count should be compared with the actual count computed by the aspect. The expected count is essentially the number of visit method execution that are needed by the computation of salary total for the complete company.