Friday, June 03, 2005

Adaptive Object Modeling and Aspect Oriented Programming

So I was reading Chris Lasater's articles on AOM at CodeProject, and it got me thinking...

At work, there's an application that's in routine flux. The past week alone I've had 3 change requests for it. It takes in Sales Leads, assigns them statuses, and then assigns the leads to users based on the state of the SalesLead object. I wrote a rudimentary RulesEngine to make my life easier with these changes, and now much of the process flow is driven by rules defined in the app.config. 95% of these changes are limited to these two operations: Assignment of Status, and Assignment to User.

In this scenario then I don't see much value in AOM. On the other hand, the RulesEngine could be more powerful. Not because it's really needed to be so far, but because it'd be cool. :)

So far the rule Consequences are simple ValueType assignments to the examined object, so no biggie. On the other hand, wouldn't it be cool if I could transfer more of the behaviour to meta-data? For example, if the phoneNumber already exists in the database, it's considered a duplicate, the status is set accordingly, and the duplicateHandler is assigned the lead. This is in code right now, and it's one of the sore spots design-wise that just gets under my skin.

What if I could move that to the business rules meta-data?

Well... I'd need support for more than just simple target value matching then. I'd need to be able to tell it to try to match that field against all SalesLeads in the database.

So I'm no whiz when it comes to AOP, but I do have a level of familiarity with Aspect#, so I'm pretty comfortable thinking I could use it to inject some pointcuts and mixins to extend the behaviour of my object. If I fleshed out the rules engine so that it could have more fully realized Condition and Consequence scenarios that'd be cool too.

Basically instead of the Controller I have now to process these objects, I could merely Parse->ApplyBusinessRules->Persist. The Controller then would be much simpler.

Just tryin' to think this through, but yeah... this seems do-able...
Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?