Simplify Your Workload

But Not Your Delivery

NCDevCon 2014

By Daria Norris / @cfGothChic

Slide Controls

  • Press right or down to advance slides
  • Press ESC to see the slide overview
  • Hold down alt and click on any element to zoom in on it
  • Alt + click anywhere to zoom back out
  • Press S to see speaker notes


reveal.js - The HTML Presentation Framework

Model View Controller


Database Interaction / Business Rules


User Interaction


Traffic Cop

FW/1 && DI/1

Convention not Configuration


  • /controllers
    • section.cfc
      • item()
  • /layouts
  • /model
    • /beans
      • name.cfc
    • /services
      • name.cfc
  • /views
    • /section
      • item.cfm
  • Application.cfc
  • index.cfm

Automatic Controller Calls


  • Application.cfc : before()
  • controllers/section.cfc : before()
  • controllers/section.cfc : item()
  • controllers/section.cfc : after()
  • Application.cfc : after()


Views are built after controllers

Layouts are built last

FW/1 3.0

Automatic Bean Factory Usage with DI/1


Features Removed

  • Service Queue - service() api function
  • startItem() & endItem()



FW/1 Application Functions

  • setupApplication()
  • setupSession()
  • setupRequest()


Use instead of onApplicationStart, onSessionStart & onRequestStart

Framework Setup


Potential Options

  • Change default home page
  • Use SES Urls
  • Set password for reloading the application
  • Set options by environment
  • Use a different bean factory than DI/1

RC Structure


Best Practices


Use the local scope for variables that only exist for the view


Include in other views and layouts with the view() function,
not <cfinclude>



Nested Layouts

  • layouts/section/item.cfm – The view-specific layout
  • layouts/section.cfm – The section-specific layout
  • layouts/default.cfm – The site-wide layout


"View" Controller

  • Param required url and form variables in rc
  • Get Domain Objects (Beans) from Services
  • Set variables for views
  • Set custom view (optional)
  • Set custom layout (optional)

"Action" Controller

  • Param required url and form variables in rc
  • Get Domain Objects (Beans) from Services
  • Call methods on Beans (& Services) to perform the Actions
  • Set return messages
  • Redirect to new location

Ajax Calls via FW/1

Best Practices


Controllers should not call other controllers


If you are tempted to break that rule,
maybe your model isn't doing enough




  • /admin
    • /controllers
    • /layout
    • /views
  • /common
    • /layout
  • /home
    • /controllers
    • /views
  • /model

DI/1 – Inject Your Services

Automatic Aliasing







Inject the Model into
Controllers & Services


component accessors="true"


property {name}Service;



Controller Example


There is No
"One True Way"

Using Patterns in Your Model

Typical Object Types

  • Beans
  • Services
  • Data Gateways



  • Where your Business Logic goes
  • Closest relationship to tables in your database
  • Also called Domain Objects



  • Coordinates tasks between objects
  • Controls the workflow between objects
  • Facilitates communication between objects

Data Gateways


  • Where the SQL lives


Also referred to as...

  • Data Access Objects (DAO)
  • Table Data Gateways

Just Use Services


There is no "Right" way



Code Examples
Uses FW/1 3.0 & Railo 4.2 or ACF11