By Peter Bell

Architecting your Views: Describing the Requirements

One of the least discussed parts of OO development in ColdFusion is the most elegant way to render your views. Some people like Steve Bryant suggest using CFCs for the UI while most others still use custom tags. This posting looks at the requirements I set for implementing my views. The next posting will outline new combined approach that is working really well for a content management system I’m developing . . .

Design Requirements
When I sat down to architect my CMS (well, actually it is my LightBase framework, but I’ve decided that a framework can learn a lot from a CMS!), I had the following design requirements:

  • Page Templates - The ability to set page templates to be used sitewide along with support for business rules allowing different pages, sections, users or even times of day to drive the page template used to render a given request.
  • Multiple Dynamic Content Areas - I can’t remember the last time I designed a site that might not have the need for a dynamic right bar showing articles relating to the practice area, products relating to the current category or something similar. The system had to support multiple dynamic content areas. For the sites that don’t need that, the 1..n content areas would just be 1.
  • Reusable Screens - It is quite possible that different parts of a site might reuse the same screen. For instance, order view in my account may be the same as the order view on the thank you page (and email) in a commerce system.
  • Extensible UI Components - If I never had to write another table or form it would be too soon. While a simple data grid is often not flexible enough, I wanted to have reusable session aware data grids supporting ordering, filtering, paging and a range of display customizations and capable of rendering in HTML (eventually I’d add the option of rendering using AJAX or Flash). I also wanted to be able to generate most of my form displays by calling the appropriate “form” component.
  • Snippets - When end clients want to be able to manage a page, I can give them a page or article admin (article admin where there might be > 1 article per page). When my resellers want to manage the layout of a checkout screen, I can provide them with easily editable HTML+ templates. The problem comes when the client needs to be able to add a custom message to the bottom of the shopping cart or under the drop down list of shipping methods that they want to change daily in the run up to Christmas. Snippets are a simple object comprised of a name and WYSIWYG description that my resellers can place anywhere in any template and the end users can manage using the admin system.
  • Separation of Concerns - There should be as close to zero code on template pages to make it easier for designers to maintain and as few graphic design decisions in the code allowing the scripts to be completely re-skinned for different sites.
  • Declarative Specification - As much as possible I want to replace custom scripts with standard libraries and a set of declarative properties which I can store in a metabase and efficiently reuse across thousands of applications.
Not like I want too much, right?!

Comments
Peter,
I would look at the Drupal CMS (PHP) and the form API that they have integrated as inspiration for Extensible UI Components. I only wish there was a comparable system for CF (yes, I have looked at farcry)
You can programatically create custom forms using arrays to define the elements, including collapible divs,etc using the API (http://api.drupal.org/api/4.7/file/developer/topic...)

Me being a CF programmer, I havent used the api programatically, drupal also allows for creation of custom forms, views, etc through a web interface. I have used drupal on numerous websites and have been able to configure it to meet 97% percent of scenarios without writing a line of code, just creating a template(theme) and configuring what is needed for the client's site
# Posted By doug s. | 12/6/06 10:04 AM
After reading your other two related posts, If you have a PHP/MYSQL environment I would recommend loading drupal to also look at how they handle theming, menus and access levels, content creation, etc as well as multiple dynamic content areas(blocks in Drupal speak)
# Posted By doug s. | 12/6/06 10:20 AM
Hi Doug,

Many thanks for the comments! Interesting you mention Drupal. I'd heard of it and just today was reading a comparison between Drupal and Joomla. Will definitely check it out - thanks for the link!

FYI, the comparison is at:
http://cmsreport.com/node/543
# Posted By Peter Bell | 12/6/06 10:33 AM
Hi Doug,

Looking at Drupal quickly, I like the features but not the implementation. I prefer a more OO approach to doing things as it is more maintainable for bigger projects, but I do think some of their ideas - suitably modified to be more OO - are great!

Thanks again for the link!
# Posted By Peter Bell | 12/6/06 10:37 AM
Drupal Programming from an Object-Oriented Perspective: http://api.drupal.org/api/HEAD/file/developer/topi...
# Posted By Ano | 12/7/06 3:21 AM
Thanks for the link!

It is a clever article, but when it comes right down to it, Drupal isn't OO. It seems to be pretty well architected for a procedural application, but while it has achieved some OO benefits without using the language constructs , it isn't the same as having an OO solution with DI, AOP, the ability to define inheritance hierarchies, etc.

Still, an interesting project!
# Posted By Peter Bell | 12/7/06 12:02 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.005.