Archive for February, 2008

Possible uses for aspect oriented programming

Aspected oriented programming seemed at first to strike me rather as a solution in search of a problem – and to a degree it still does – So I thought I might try to record various problems that aspect oriented programming might solve as they come to mind or I come across them.

Observer Pattern

The observer pattern tends to result in “notify” function calls being littered throughout the observed object. These can be replaced by a single aspect – thereby separating out the “being observered” behaviour of the observed object from the rest of its behaviour.

To clarify, given some object we can turn it into an observed object by adding a notify method and an aspect that calls this method whenever a modifier is called. If all the modifiers start with “set” or return void then this could be particularly easy to do and if one could be sufficiently consistent throughout one’s codebase – one could imagine having a “subject mixin”, that makes an object observed witout the object being otherwise modifed. All that would be required would be a standard way to identify all the modifiers such that an aspect could be applied to them.

Switching caching of function returns on and off at compile time

One could have a separate caching aspect that adds code before a pointcut to check if a value is in a dictionary, and if so return the stored value. Some care would have to be taken to create this dictionary and store it in an appropriate place.

One could then control caching throughout the application from one locatio.

Restricting access to certain functions based on userĀ 

Our aspect would add code that checks the users permissions and dies and raises exceptions if the permission is not set. (This idea is adapted from here

Doing anything that you might want to do with decorators in python

Decorators in python are quite similar to aspects – but decorators (usually) are applied when the function is defined. (I’m sure one can do crazy things with metaclasses so as to fit aspect oriented programming to python if one so desired… it would all be done at runtime however…)


February 25, 2008 at 2:36 pm Leave a comment

A book on parsing

Seems quite complete…

February 12, 2008 at 2:30 am Leave a comment

Refactoring Thesis

Here is a fun thesis on the programmatic automation of refactoring.

February 12, 2008 at 2:28 am Leave a comment


I found something called XRefactory today – a set emacs macros for doing refactoring, and several other clever code related things. The only issue is:

  • The C++ version is proprietary and costs money.
  • The free version (for C and java) doesn’t appear to be open source.

But besides this, it looks quite fun.

February 12, 2008 at 2:28 am Leave a comment

February 2008
« Jan   Mar »