Building Pages with a Page Object

I was reading through PHP and MySQL Web Development at the local bookstore the other night when I noticed that their example code for explaining object oriented concepts was a Page class that basically built a page based on its properties. While the concept of directly building the return code string by string is a little foreign to ColdFusion, I was very interested in the idea of an extensible Page object that could help me manage my applications. Read more to see what I came up with.

 


CF on Wheels: What I Like

CF on Wheels LogoOver the last few days, I've taken the time to make myself a little more familiar with CF on Wheels, and I've I'm really digging it. CF on Wheels bills itself as a ColdFusion framework "in the spirit of Ruby On Rails," and I think it lives up to the tag line. Click "more" to read more about it.

 

Ruby on Rails: What I Like

I started a short series of blogs about what I like in a number of modern frameworks/web programming environments. This is part of an effort to find what really works in these languages, and to see how best I can port them to ColdFusion. This time around its the king of RAD, Ruby on Rails.

Rails is all the rage these days, so its hard not to compare any framework to the "RoR". Its even harder when lost of frameworks for existing languages are inspired by Ruby on Rails, and try to re-implement things it does in their own language. You know what they say: "Imitation is the sincerest form of flattery." Now its time for me to see what I like.

 

CakePHP: What I like

I've been doing a lot of thinking about frameworks lately, and about how much work it is to get a MVC/Model2 framework going in ColdFusion compared to in other languages/servers. This lead me to investigate the documentation for a number of non-ColdFusion server/frameworks that I've used, or are popular, and I've been trying to round out a list of what I like and why.

The first installment of this mini-series is on CakePHP. Please remember that while I may have used some of these frameworks, I'm not an expert, so I might be missing the thing that makes that framework cool. If so, let me know that you think the best parts of the framework are, and I'll see if I agree.

 

IIS vs onMissingTemplate

Several weeks back I was exposed to Python and Django for the first time, and it really got me thinking. While I'm not a huge fan of Python syntax, I really did like the setup for Django, and how it implements MVC. One of the first things that I loved was this little tid-bit for linking up URL requests to views:

from django.conf.urls.defaults import *

urlpatterns = patterns('',
(r'^polls/$', 'mysite.polls.views.index'),
(r'^polls/(?P<poll_id>\d+)/$', 'mysite.polls.views.detail'),
(r'^polls/(?P<poll_id>\d+)/results/$', 'mysite.polls.views.results'),
(r'^polls/(?P<poll_id>\d+)/vote/$', 'mysite.polls.views.vote'),
)

In that block, Django is defining regular expressions that map to Python functions, and defining how to pull named variables out of that regular expression, so that if you requested /polls/23/ becomes a call to the mysite.polls.views module to do the following:

# mysite.polls.views is the module, details is the function
detail(request=<HttpRequest object>, poll_id='23')

Isn't that cool? I'd love to be able to do that in ColdFusion, but it looks like there are a number of hurtles I have to get past before I can make this work:

  1. How do I make ColdFusion get the variables out of that URL path?
  2. How do I make ColdFusion look at a URL that doesn't exist?

 

Leveraging Popular Frameworks

This contains info from the CFUnited talk on this topic.

This talk covers MVC, Factories, ORM Introducing a quick start application: AppBooster

Domain & Business objects for each Entity.

Business Object (bean) - people, places, and things, the nouns in your system. Data Access Objects (DAO) - read and save objects Gateways - Objects which return queries Service Object (SO) - your API (controllers do not touch BO, DAO, or Gateway) Controllers - talk to your service layer.

Q: Where is validation at? A: In the BO, or the SO.

Frameworks and Software Layers

DB Layer (ORM) Transfer, Reactor

continue later

 

More Entries

Jon Hartmann, July 2011

I'm Jon Hartmann and I'm a Javascript fanatic, UX/UI evangelist and former ColdFusion master. I blog about mysterious error messages, user interface design questions, and all things baffling and irksome about programming for the web.

Learn more about me on LinkedIn.