Archive for the ‘aspect orientated programming’ Category
… AspectJ Orientated Programming Continued
Last month I wrote briefly about a computer science seminar course that I am taking, Programing Skills: Aspect Orientated Programming.
The best way to show the differences between AOP and the “classic” OOP (object orientated programming) paradigm is the Observerable design pattern.
For example: Take a LinkedList that you wish to monitor.
- Whenever the list is changed, print “List is changed”
- Whenever the list is changed, print if the list is empty
To do this with the classic OOP Observable pattern, you have to create two Observer classes (extending some sort of super Observer class ), make your LinkedList implement the Observerable class, and make a test class to attach said Observers to your LinkedList.
To do the same in AOP, you simply make an Aspect – that watches when your class has been accessed, and acts accordingly based on advice that you give it.
Code below, read entire post for snippets.