# Tools for Separating Good Coupling from Bad Coupling Using Aspects

Coupling between software modules is unavoidable. In 1988 we proposed a style rule for OOD and OOP, called the Object Form of the Law of Demeter (LoD) to separate good coupling from bad coupling in OO. In 1992 we proposed a programming construct, called propagation patterns that were based on a concern-specific dynamic join point model, to better follow the LoD. It took another decade and the general-purpose dynamic join point model of AspectJ to make it convenient to express the LoD using aspects. The paper shows an elegant solution and gives input to the further development of aspects and AspectJ.

Paper: AOSD 2003 paper

## Tools and instructions how to use them

### For AspectJ 1.0.6

Code by Paul Freeman based on Pengcheng Wu's and David Lorenz' solution Check HW4_Solution.txt and part 3. This is a "production version" of the Object Form checker used in an Eclipse plug-in. Installation Instructions

Checker code repository maintained by Pengcheng Wu It is closely aligned with the paper.

Pengcheng Wu started in Spring 2002 on a Law of Demeter (LoD) checker and David Lorenz joined us in the Summer. In the Fall 2002 we had a graduate class of 25 students develop a checker (http://www.ccs.neu.edu/home/lieber/com3205/f02/f02.html) and in November 2002 we are still fine-tuning our checkers. Paul Freeman made several improvements to the Object Form Checker during the Fall 2002 quarter: http://www.ccs.neu.edu/home/lieber/com3205/f02/solutions/com3205/hw04/ The Object Form checker is being integrated into Eclipse.

AspectJ is a great language but it is not easy to write sophisticated join point predicates. Discussion between Paul Freeman and Pengcheng Wu on LoD Checker Design.

### For AspectJ 1.2.1

Conference Publication

@INPROCEEDINGS{llw:SEA-03,
AUTHOR = "Karl Lieberherr and David H. Lorenz and Pengcheng Wu",
TITLE = "A Case for Statically Executable Advice: Checking the Law of Demeter With AspectJ",
BOOKTITLE = "Second International Conference on Aspect-Oriented Software Development",
YEAR = "2003",
PAGES = "",
EDITOR = "Mehmet Aksit",
PUBLISHER = "ACM Press"
}

@TECHREPORT{wu:SEA-02,
AUTHOR = "Karl Lieberherr and David H. Lorenz and Pengcheng Wu",
A Case Study in Checking Style Rules with Aspects",
INSTITUTION = "Northeastern University",
YEAR = 2002,
MONTH = "October",
NUMBER = "NU-CCS-02-11"
}

-- Karl Lieberherr

Law of Demeter Information:

@INPROCEEDINGS{LHLR:law-paper,
AUTHOR = "Karl J. Lieberherr and Ian Holland and Arthur J. Riel",
TITLE = "Object-oriented programming: An objective sense of style",
BOOKTITLE = oopsla,
MONTH = "September",
YEAR = "1988",
VOL = 23,
NUMBER = 11,
PAGES = "323-334",
NOTE = "A short version of this paper appears in
{\em IEEE Computer Magazine},
June 1988, Open Channel section, pages 78-79."
}
%  A revised version
%  of the paper appeared in IEEE Software in fall 1989."

@ARTICLE{karl-ian:soft1,
AUTHOR = "Karl J. Lieberherr and Ian Holland",
TITLE = "Assuring Good Style for Object-Oriented Programs",
JOURNAL = ieee-software,
YEAR = "1989",
MONTH = "September",
PAGES = "38-48"
}



This paper sparked our investigation of Aspect-Oriented Programming.

Problems in developing the LoD checker in AspectJ.

while developing the LoD checker, we noticed the following difficulty: It was a challenge to make the program a true observer that never changes the behavior of the observed program. We had used the LoD checker for several months on small programs when the checker suddenly produced an infinite loop (changing the behavior of the observed program). It took several hours of debugging work to find the bug. The problem was, if I remember correctly, that the checker advised code in itself.

Maintained by Karl Lieberherr