160 likes | 334 Views
Fusebox & CFCs. Barney Boisvert 2004 Fusebox Conference. Problems with FB. The “DO in XML” problem Grammar is not full-featured Need query/list/index loops Need nested conditionals Etc. XML is cumbersome No nested layouts?!?!. Two Key Concepts. Encapsulation - being self contained
E N D
Fusebox & CFCs Barney Boisvert 2004 Fusebox Conference
Problems with FB • The “DO in XML” problem • Grammar is not full-featured • Need query/list/index loops • Need nested conditionals • Etc. • XML is cumbersome • No nested layouts?!?!
Two Key Concepts • Encapsulation - being self contained • FB doesn’t really do this • CFCs provide help • Abstraction - separate interface from implementation • FuseDocs do this for fuses (mostly) • CFCs excel at it Both of these contribute greatly to the long-term maintainability of code.
Parts of an App Check out this column * You can use CFM templates for this, but it’s messy † You can use FB behind a CFC façade, but that’s even messier
So what is FB? A framework, of course, but what kind? • Application (typical use) • UI (implied by application) • HTTP/text-based (definitely) • Flash (not a chance) • Web Services (ugly, but possible, with CFC help) What about Mach-II? Struts? Ben Hediard’s MVCF (www.benorama.com)?
What’s different? • Clear distinction between action and display requests • Clear distinction between UI logic and business logic • Ability to “scalp” the app at any layer, and leave a functional remainder
Why is it different? • FB controller circuit has ALL public fuseactions, both action and display • FB can potentially combine action and display fuseactions • FB’s business logic depends on the controller and it’s framework “Does this have anything to do with user interaction?”
Other benefits of CFCs • Can be stateless or stateful • Can easily integrate with Flash & web services • Can be [nearly] transparently replaced with Java or COM • Can be fully encapsulated • More effective testing • No weird assemble-time interferences • Objects can provide easier/better modeling • Help remove that pesky ozone layer
Why Use FB At All? • Procedural nature of HTML clients • FB is awesome at managing text layouts • FB’s already coded, tested and functional
Weighing Frameworks Balancing current needs, anticipated needs, and overhead • I still write pure FB apps (even single-circuit ones) • I never do framework-less apps
Building CFC-based Models • Objects (user, product, etc.) • Processes (add user, check out, etc.) • Collections (user list, cart contents, etc.) • Business Objects & DTOs • Services • Gateways