| By Peter Bell | Article Rating: |
|
| December 24, 2006 10:30 PM EST | Reads: |
15,578 |
Sometimes people without an object-oriented programming background get confused by what ColdSpring does because it solves a problem they don't yet know they have. I'd start by throwing your objects into an application scope to get a sense of the problems that causes. Once that starts to become a problem, head on over to www.coldspringframework.org and it should make perfect sense!
If you know what an Active Record pattern is and find yourself wishing that ColdSpring was optimized for injecting dependencies into transient Business objects as well as singeltons (which it isn't), you might want to check out LightWire at http://lightwire.riaforge.org.
Understanding the Controller
The most
misunderstood part of a well-designed object-oriented application is
the controller. In the past our "controller" methods often did a lot of
work. In a well-architected OO application, they do very little indeed.
The job of a controller is to do two things. First it should take
values from the URL, form, and (possibly) session scope to make
well-parameterized calls to the appropriate method in the model. Second
it should take the information returned by the model and pass it to the
appropriate view for displaying on-screen. That's pretty much it!
Recently there have been a lot of questions about how to integrate Model-Glue and Mach-II with Flex front-ends or Web Service calls. The answer is that you don't. The Flex front-ends and Web Service calls should speak to the model directly (well, actually via a simple remote façade to handle any differences in data formatting between the model and the remote system). They shouldn't speak to your HTML controller (such as a Mach-II or Model-Glue controller) at all. If you feel you need to make your Flex applications or Web Services speak to your HTML controller because otherwise you'd have to replicate business logic, that's a perfect sign that you've put too much business logic into your controller and that you need to refactor that and put it into your model instead.
Looking at Views
The goal of a view is to display
the information that the model provided to the controller along with
any templates, formatting, and the like. There should be no business
logic in the views (such as calculating prices or deciding what value
to display based on business rules). The view should never include a
cfquery that runs against a database (a query of queries for sorting or
ordering a recordset may sometimes make sense).
Other than the general rules above, there aren't well-accepted patterns in the ColdFusion community for handling view issues like skinning, view composition (so you can reuse parts of your views on multiple pages), and view helpers (to provide a separation of concerns by removing any programming logic from your templates so designers can safely edit the templates without breaking view-specific code like alternating row tables or "records per page" display logic). However, there are many approaches being explored so it's well worth looking at them.
Conclusion
Using cfcs for your application can
make complex applications much more maintainable, but there's a
substantial learning curve. Wherever possible, start with small test
applications and then as you get more confident using the patterns
you'll find your development speed increasing. If you have to start
with an existing system, solve one problem at a time. Pull your data
access logic into DAOs. Then start to add a service layer and remove
business logic from your views and controllers one at a time. The
trick? Lots of little steps!
Published December 24, 2006 Reads 15,578
Copyright © 2006 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Peter Bell
Peter Bell is CEO/CTO of SystemsForge (http://ww.systemsforge.com) and helps Web designers to increase their profits and build a residual income by generating custom web applications - in minutes, not months. An experienced entrepreneur and software architect with fifteen years of business experience, he lectures and blogs extensively on application generation and ColdFusion design patterns (http://www.pbell.com).
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Adobe May Cooperate with Apple to Transplant Flash Player to iPhone
- Adobe Flex Developer Earns $100K in New York City
- Adobe LiveCycle Enterprise Suite 2 for Cloud Computing
- Adobe Betas Target RIAs and Cloud Computing
- Adobe Cans Another 9% of its Workforce
- Moyea DVD4Web Converter V2.0 Converts DVD to FLV Fast and Synchronously with Watermarks
- Adobe Fiddles with its Web Apps
- Adobe & Salesforce Cut Cloud Deal
- Hosting.com Launches ColdFusion 9 in the Cloud
- The Real Time Infrastructure Ultimatum
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Eval JavaScript in a Global Context
- Fig Leaf Software to Exhibit at Government IT Conference & Expo
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Is Microsoft as Free as Open Source?
- Adobe Reader Sued
- The Planet Named “Bronze Sponsor” of Cloud Computing Expo
- Microsoft Expression Web Has Got Game
- Adobe May Cooperate with Apple to Transplant Flash Player to iPhone
- Adobe Flex Developer Earns $100K in New York City
- Bruce Chizen Joins Voyager Capital as Venture Partner
- My Top Seven Wishes From Adobe MAX 2009
- The Next Programming Models, RIAs and Composite Applications
- Where Are RIA Technologies Headed in 2008?
- Constructing an Application with Flash Forms from the Ground Up
- AJAX World RIA Conference & Expo Kicks Off in New York City
- CFEclipse: The Developer's IDE, Eclipse For ColdFusion
- Personal Branding Checklist
- Adobe Flex 2: Advanced DataGrid
- Has the Technology Bounceback Begun?
- Building a Zip Code Proximity Search with ColdFusion
- i-Technology Viewpoint: We Need Not More Frameworks, But Better Programmers
- The Asynchronous CFML Gateway
- Web Services Using ColdFusion and Apache CXF





















