Multi-Class Class Helpers
This is cool. I figured out a way to assign the same class helper to multiple classes in Delphi 2007. Marco Cantu asked me if I knew how to do this during CodeRage II, and then David I. mentioned that Class Helpers should be used to implement Aspect Orientated Programming (AOP), but since they don’t support assigning the same class helpers to multiple classes that wouldn’t work.
I’ll write this up later. It isn’t a best case scenario, and requires a few extra lines of code, but it accomplishes what I set out to do, and that is pretty dang cool! Hopefully later CodeGear will extend class helpers and make this and other cool stuff easier. . .
Tags: AOP, Aspect Orientated Programming, class helper, Delphi
December 3rd, 2007 at 9:49 pm
Surprise to hear that this is possible
Wonderful. I thought that only those VM-ed language or scripts could do it well.
December 3rd, 2007 at 11:00 pm
Class helper for TObject?
December 4th, 2007 at 12:40 am
A class helper for TObject or any other common descendant would work, but I figured out a way to assign it to only the specific objects you want, without adding it to the other objects. Although it does have some limitations I am trying to work around. May not be as useful as I originally thought. I’ll keep you posted.
December 14th, 2007 at 10:14 am
Any advance on this?
Also, do you have some pointers on how (multiple) class helpers can be used for AoP? I suppose it’s related to the “override-even-if-not-virtual” feature of class helpers.