Contracts would most likely be far more useful to more people than the whole mess that AOP seems to be.
Still haven’t quite come up with a decent use case beyond injecting logging either. Stuff like transaction handling is critical to functionality and logic and I seriously wouldn’t want to leave it in the hands of a bit of code miles away which I had no idea was even executing… whereas logging isn’t.
What might have been nice in Java is a way to annotated how extension points in abstract classes were meant to be used. I find myself using this pattern a lot:
public final void tick() {
doTick();
}
protected abstract void doTick();
or this:
public final void tick() {
doTick();
}
protected void doTick() {
// By default, do nothing special
}
with the expectation that the derived class implements doTick(). However what is the rule for a further derived class? I end up with having to remember to do this:
@Override
protected void doTick() {
super.doTick(); // Don't forget to do this FIRST or everything breaks!
// blah
}
or this:
@Override
protected void doTick() {
// blah
super.doTick(); // Don't forget to do this LAST or everything breaks!
}
or even this:
protected final void doTick() {
// blah
doTickMoreStuff();
}
protected abstract void doTickMoreStuff() {
… and so on. Some keywords or annotations to help enforce the accepted method of extension would solve a lot of that.
I digress. Back to work. In C#. Gah.
Cas