|
I really wasn't getting ColdSpring, and I stumbled across http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/413268, Zoran Isailovski's "Dependency Injection The Python Way" recipe. A calling object just specifies that the provider of a given feature must meet certain assertions. Then the calling object doesn't need to know anything about the actual provider. There's an involved discussion of whether this better fits the criteria for "DependencyInjection" or "ServiceLocator", but I like the way it works, whatever it's called. It has a solid "five star" rating on ASPN's site.
I figured since Pythonistas have been doing duck-typed OOP for a long time, it might port over to ColdFusion, and maybe I'd learn as I went. So, I ported it over to CFML. Maybe someone else already did it and I just didn't see it. It's nice, not too heavy about 200 lines total in the CFC's that make it work. No XML sit-ups, either I like everything being "on the fly" instead of set up in advance.
Anyway, there's a demo page and a test page in the zip file at: http://uber.engineer.co.summit.oh.us/assets/app_tools/dependency_injection.zip If you want to have a play, you'll need to tweak the CFC path in all but the "testCFC.cfc" file.
If you do take a look, and you like what it does, please pass along any suggestions to tighten up the code or improve the idea. For that matter, if it's handy, but I'm calling it by the wrong Pattern, let me know that, too. It was mainly a learning exercise for me, but I think I might just use it for real.
Ron
----------------------------------------------------------You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). An archive of the CFCDev list is available at www.mail-archive.com/[email protected] |
- [CFCDev] Dependency Injection for Dummies? Ron Phillips
