Merlin: Decisions, Decisions, Decisions
This is part three of a series on Merlin. I recommend you read from the beginning.
So I knew I was going to build an Outlook style Rules Wizard, but how should it work? I figured there were two general approaches I could take.
- Write/compile code on the fly using the CodeDOM API
- Create some kind of "processing engine" and drive it with meta-data
The first approach sounded cool, but I knew that programming against the CodeDOM API could be quite cumbersome. I was also concerned that many security-minded administrators would hesitate to install an add-on that was busy compiling code on a production server (never mind that that's exactly what ASP.NET does). The second idea seemed more feasible, but also sounded like a lot of work. Maybe I could somehow leverage existing CS "stuff"? Okay, great idea...but what?
For some reason, my thoughts started to wander back the first contest, where our goal was to create a cool CSModule. In my mind, Merlin was beginning to sound like an easy way to create a CSModule, without coding. After all, I realized that the primary tasks in creating a CSModule were to wire up the correct event handlers and then write code for what should happen. What I wanted to do was to loosen the coupling between the condition and the action.
So I walked thru a specific example, auto-creation of a blog. At some point in time, we heard the desire that newly registered users get a blog automagically. So a developer took the time to write a CSModule that would trap the user creation event and then create a blog for that user. An option was added to the control panel which allowed administrators to turn the feature on/off. But what if blogs were to be reserved for users who are really contributing to the site (determined by points or post count or length of membership). Couldn't we somehow leverage the same code at a different time? Unfortunately, the answer was, not easily. You could copy the CSModule, tweak it, compile it, upload it to the server, and add it to the configured list of CSModules, but that seemed like too many steps; not to mention that there was no way to turn the feature on/off (without removing the configuration item).
Having chosen to leverage the CSModules framework, I still needed to figure out how to avoid the code/compile/upload/configure approach... (continued)