Friday, November 25, 2011

Roles, Classes & Aspect programming.

Intensive conversation with Simon.

We got talking about ways of thinking about how you might abstract over both object
oriented sytle inheritance and aspect programming.

Simon said something interesting
Imagine your class is a dictionary. You have selectors ( method names) for keys and code ( or source code) as when one class is derived from the other ( Doctor is derived from person). What you are trying to do is merge the Doctor dictionary with the person dictionary. Most cases are the same 'Heal()' is in the doctor dictionary and not in the person and 'Breath()'is in person but not doctor so merging these dictionaries no problem, is only when the selectors are the same ('Jump'()) do you have to do some code splicing.

I pointed out that Apsect programming can also consider it as merging two (or more) dictionaries together with more fancy splicing.

Simon wants to think about Role centred programming - a role is like a class but when you aggregate the exposed interface remains exposed. So a you can combine an driver role and a doctor you get a ambulance driver. The probelm is how to handle the overlaps when you effectively merge the dictionary.

It was the kind of intensive conversation that makes you glad your an academic. On the down side Gordon my prize Phd student can't afford to go on to full phd.

No comments: