SlideShare a Scribd company logo
CFWheels
Pragmatic, Beautiful code
Indy Nagpal
Straker Software
Melbourne, November 2010
A bit about me
•  CTO, Straker Software, New Zealand
•  Been doing CF (and Flex) for a while
•  Cloud-based CF Using Railo
•  In love with Ruby (the language) & Rails
– Was in love with Groovy (still am, I think)
•  nagpals.com/blog
Rapid ≠ Agile
Agile
•  Early, continuous delivery of software
•  Welcome changing requirements
•  Deliver working software frequently
•  Working software = progress
•  Technical excellence and good design
•  Simplicity is essential – work not done
“There comes a time in the history of
every project when it becomes
necessary to shoot the engineers and
begin production.”
Need
•  Quickly build and deploy database-driven
web apps
•  Rapid iterations in a testable fashion
•  Easy for multiple developers to understand
•  Working app is more important than
configuring the app
Search…
•  Tried lots of frameworks/methodologies
•  Ruby on Rails addressed most issues
•  Learn another language and framework
•  Defeats the whole purpose
•  Enter, CFWheels…
What is CFWheels
•  Framework inspired by Ruby on Rails
•  Simple organization system
•  Suited for typical, database-driven web
applications
•  A couple of years’ old – fairly mature
Convention over configuration
•  Possibly the single most important thing
•  Mostly convention, minor configuration
•  Easy to
– turn on
– tune in
– drop out
Directory structure
•  webroot
– models	
– controllers	
– views	
– images	
– javascripts	
– stylesheets	
– plugins	
– tests	
– events	
– config
Intuitive Code Structure
•  View
–  Responsible for display and user interaction
–  Receive data from controller
•  Controller
–  Process requests from view
–  Get/process data from model
–  Make data available to the view
•  Model
–  Interacts with the database layer
–  Responsible for validation
–  Other methods to process/message data
Convention - URLs
•  URLs mapped to controllers/models/views
http://blog/posts/edit/1	
Controller: Posts
Model: Post
Action: Edit
Key: 1
View – http://blog/posts/
/views/posts/index.cfm	
<cfparam name="posts">	
<ul>	
<cfoutput query="posts">	
	<li>	
	 	#linkTo( 	text 	= "#posts.title#", 	
	 	 	 	action	= "edit", 	
	 	 	 	key 	= post.id, 	
	 	 	 	title 	= "Edit #posts.name#"	
	 	 	 	)#	
	</li>	
</cfoutput>	
</ul>
Controller – http://blog/posts/
/controllers/Posts.cfc	
<cfcomponent extends="Controller">	
<cfscript>	
	function index(){	
	 	posts = model("post").findAll(order="createdAt")	
	}	
</cfscript>	
</cfcomponent
Model – http://blog/posts/
/models/Post.cfc	
<cfcomponent extends="Model">	
<cfscript>	
	function init(){	
	 	belongsTo("author")	
	 	hasMany("comments")	
	 		
	 	validatesLengthOf( 	properties 	= 	"title",	
	 	 	 	 	minimum 	= 	10,	
	 	 	 	 	maximum 	= 	255)	
	}	
</cfscript>	
</cfcomponent>
Convention – Files & Database
•  Place in appropriate folders – MVC
•  Plural database names, singular model
names
– DB Table: posts	
– Model: Post.cfc	
•  Database fields: id, createdat, updatedat
Built-in ORM
•  Simple and elegant
•  All major databases supported
•  Almost no setup required – baked in
•  CRUD instantly available via models/plugin
•  Finding data using “finders”
–  findOne(), findAll(), findByKey()…
Associations
models/Post.cfc	
<cfcomponent extends="Model">

<cfscript>	
	 	function init(){	
	 	 	belongsTo("author")	
	 	}	
</cfscript>

</cfcomponent>	
models/Author.cfc	
<cfcomponent extends="Model">

<cfscript>	
	 	function init(){	
	 	 	hasMany("posts")	
	 	}	
</cfscript>

</cfcomponent>	
<cfscript>	
	posts 	= model("post").findAll(include="author")	
	author 	= model("author").findOneByKey(key=params.key,include="posts")	
</cfscript>
Dynamic Finders
•  Dynamic finders are magical
model("user").findOne(where="username='bob' and password='pass'")	
rewritten as
	model("user").findOneByUsernameAndPassword("bob,pass”)
URLs and Routing
•  Beautiful URLs
–  http://blog/a-good-url	
•  Powerful routing mechanism
	<cfset addRoute( 	name 	 	= "showPost", 

	 	 	pattern	 	= "/[key]”,

	 	 	controller 	= "Posts",

	 	 	action	 	= "show")>
•  Can be turned REST-full
Multiple response formats
•  http://blog/posts	
•  http://blog/posts.xml	
•  http://blog/posts.json	
•  http://blog/posts.csv	
•  http://blog/posts.pdf
Common tasks done
•  Adding timestamps
•  Flashing messages
•  Pagination
•  Sending multi-part emails
•  Redirecting users
Lots of helper functions
•  Views
selectBox()	
linkTo()	
timeAgoInWords()	
paginationLinks()	
titleize()	
pluralize()	
•  Model
validatePresenceOf()	
findAll()	
findOneByKey()	
afterSave()	
•  Controller
flash()	
isGet()	
sendMail()
Plugins
•  Neat architecture to add/override
functionality
•  Extremely useful
– Scaffold –generate CRUD application
– DBMigrate – Add/edit database structure
– Remote Form Helpers – Ajax with forms
– Localizer – Localizing an application
Baked in testing
•  Ships with RocketUnit
<cfcomponent extends="tests.Test">	
<cfscript>	
	function test_1_get_timezones(){	
	 	qTimezone 	= model("Timezone").getTimezones()	
	 	assert("isQuery(qTimezone) ")	
	 	assert("qTimezone.recordcount eq 56")	
	}	
	 	 		
</cfscript>	
</cfcomponent>
Environments
•  Different setup for applications based on
stages of development
– Design, Development, Production, Testing,
Maintenance
•  Differ in terms of caching, error-handling
•  Switch environments via config/url
Docs/Support
•  Very helpful docs at cfwheels.org
•  Active and supportive mailing list
•  Quite a few screencasts
•  Direct knowledge transfer from Ruby on
Rails books/docs (e.g., Head First Rails)
•  Bunch of blogs
IDE Support
•  Eclipse, CFBuilder
– Syntax Dictionary
•  Textmate
– Bundle
•  Coda
– Lacking, but works by adding Clips
Beauty
•  Simple code organization and flow
•  Easy to understand code – eyeballing code
•  Common tasks done with minimal code
•  Pretty URLs
•  Almost zero configuration, with power to
configure as much as needed
Pragmatic
•  Focus on simple code that solves issues
•  Trades pure OO for simplicity and structure
•  Easy to not use the framework if needed
•  Common web application problems already
solved – why reinvent the wheel(s)!
Wrap up
•  Evaluate if you need a ‘framework’
•  Learn URL rewrites (Apache, IIS)
•  Dabble with Ruby on Rails
•  cfscript = succinct code
•  Worth trying out just to see how problems
can be solved in a different manner
Thank you
Questions?
indy@nagpals.com	
nagpals.com/blog

More Related Content

What's hot

RavenDB 3.5
RavenDB 3.5RavenDB 3.5
RavenDB 3.5
Oren Eini
 
RavenDB 4.0
RavenDB 4.0RavenDB 4.0
RavenDB 4.0
Oren Eini
 
Infinum Android Talks #09 - DBFlow ORM
Infinum Android Talks #09 - DBFlow ORMInfinum Android Talks #09 - DBFlow ORM
Infinum Android Talks #09 - DBFlow ORM
Infinum
 
Innovating faster with SBT, Continuous Delivery, and LXC
Innovating faster with SBT, Continuous Delivery, and LXCInnovating faster with SBT, Continuous Delivery, and LXC
Innovating faster with SBT, Continuous Delivery, and LXC
kscaldef
 
Real World Rails Deployment
Real World Rails DeploymentReal World Rails Deployment
Real World Rails Deployment
Alan Hecht
 
Simplify integrations-final-pdf
Simplify integrations-final-pdfSimplify integrations-final-pdf
Simplify integrations-final-pdf
Christian Posta
 
Why ruby and rails
Why ruby and railsWhy ruby and rails
Why ruby and rails
Reuven Lerner
 
4 JVM Web Frameworks
4 JVM Web Frameworks4 JVM Web Frameworks
4 JVM Web Frameworks
Joe Kutner
 
Automating JavaScript testing with Jasmine and Perl
Automating JavaScript testing with Jasmine and PerlAutomating JavaScript testing with Jasmine and Perl
Automating JavaScript testing with Jasmine and Perl
nohuhu
 
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
Derek Collison
 
Zapping ever faster: how Zap sped up by two orders of magnitude using RavenDB
Zapping ever faster: how Zap sped up by two orders of magnitude using RavenDBZapping ever faster: how Zap sped up by two orders of magnitude using RavenDB
Zapping ever faster: how Zap sped up by two orders of magnitude using RavenDB
Oren Eini
 
About Caching
About CachingAbout Caching
About Caching
Weng Wei
 
MongoDB Days UK: Using MongoDB to Build a Fast and Scalable Content Repositor...
MongoDB Days UK: Using MongoDB to Build a Fast and Scalable Content Repositor...MongoDB Days UK: Using MongoDB to Build a Fast and Scalable Content Repositor...
MongoDB Days UK: Using MongoDB to Build a Fast and Scalable Content Repositor...
MongoDB
 
Don't worry with bower
Don't worry with bowerDon't worry with bower
Don't worry with bower
Frank van der Linden
 
Zend Framwork presentation
Zend Framwork presentationZend Framwork presentation
Zend Framwork presentation
Uva Wellassa University
 
Javascript on Server-Side
Javascript on Server-SideJavascript on Server-Side
Javascript on Server-Side
ASIMYILDIZ
 
DrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalabilityDrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalability
cherryhillco
 
JSF2
JSF2JSF2
Building Enterprise Grade Front-End Applications with JavaScript Frameworks
Building Enterprise Grade Front-End Applications with JavaScript FrameworksBuilding Enterprise Grade Front-End Applications with JavaScript Frameworks
Building Enterprise Grade Front-End Applications with JavaScript Frameworks
FITC
 
Hands-on Performance Tuning Lab - Devoxx Poland
Hands-on Performance Tuning Lab - Devoxx PolandHands-on Performance Tuning Lab - Devoxx Poland
Hands-on Performance Tuning Lab - Devoxx Poland
C2B2 Consulting
 

What's hot (20)

RavenDB 3.5
RavenDB 3.5RavenDB 3.5
RavenDB 3.5
 
RavenDB 4.0
RavenDB 4.0RavenDB 4.0
RavenDB 4.0
 
Infinum Android Talks #09 - DBFlow ORM
Infinum Android Talks #09 - DBFlow ORMInfinum Android Talks #09 - DBFlow ORM
Infinum Android Talks #09 - DBFlow ORM
 
Innovating faster with SBT, Continuous Delivery, and LXC
Innovating faster with SBT, Continuous Delivery, and LXCInnovating faster with SBT, Continuous Delivery, and LXC
Innovating faster with SBT, Continuous Delivery, and LXC
 
Real World Rails Deployment
Real World Rails DeploymentReal World Rails Deployment
Real World Rails Deployment
 
Simplify integrations-final-pdf
Simplify integrations-final-pdfSimplify integrations-final-pdf
Simplify integrations-final-pdf
 
Why ruby and rails
Why ruby and railsWhy ruby and rails
Why ruby and rails
 
4 JVM Web Frameworks
4 JVM Web Frameworks4 JVM Web Frameworks
4 JVM Web Frameworks
 
Automating JavaScript testing with Jasmine and Perl
Automating JavaScript testing with Jasmine and PerlAutomating JavaScript testing with Jasmine and Perl
Automating JavaScript testing with Jasmine and Perl
 
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
 
Zapping ever faster: how Zap sped up by two orders of magnitude using RavenDB
Zapping ever faster: how Zap sped up by two orders of magnitude using RavenDBZapping ever faster: how Zap sped up by two orders of magnitude using RavenDB
Zapping ever faster: how Zap sped up by two orders of magnitude using RavenDB
 
About Caching
About CachingAbout Caching
About Caching
 
MongoDB Days UK: Using MongoDB to Build a Fast and Scalable Content Repositor...
MongoDB Days UK: Using MongoDB to Build a Fast and Scalable Content Repositor...MongoDB Days UK: Using MongoDB to Build a Fast and Scalable Content Repositor...
MongoDB Days UK: Using MongoDB to Build a Fast and Scalable Content Repositor...
 
Don't worry with bower
Don't worry with bowerDon't worry with bower
Don't worry with bower
 
Zend Framwork presentation
Zend Framwork presentationZend Framwork presentation
Zend Framwork presentation
 
Javascript on Server-Side
Javascript on Server-SideJavascript on Server-Side
Javascript on Server-Side
 
DrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalabilityDrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalability
 
JSF2
JSF2JSF2
JSF2
 
Building Enterprise Grade Front-End Applications with JavaScript Frameworks
Building Enterprise Grade Front-End Applications with JavaScript FrameworksBuilding Enterprise Grade Front-End Applications with JavaScript Frameworks
Building Enterprise Grade Front-End Applications with JavaScript Frameworks
 
Hands-on Performance Tuning Lab - Devoxx Poland
Hands-on Performance Tuning Lab - Devoxx PolandHands-on Performance Tuning Lab - Devoxx Poland
Hands-on Performance Tuning Lab - Devoxx Poland
 

Viewers also liked

Testing For Success
Testing For SuccessTesting For Success
Testing For Success
indiver
 
Make It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version ControlMake It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version Control
indiver
 
Using NoSQL MongoDB with ColdFusion
Using NoSQL MongoDB with ColdFusionUsing NoSQL MongoDB with ColdFusion
Using NoSQL MongoDB with ColdFusion
indiver
 
ITB2016 - NoSQL with mongodb and ColdFusion (CFML)
ITB2016 - NoSQL with mongodb and ColdFusion (CFML)ITB2016 - NoSQL with mongodb and ColdFusion (CFML)
ITB2016 - NoSQL with mongodb and ColdFusion (CFML)
Ortus Solutions, Corp
 
CommandBox : Free CFML
CommandBox : Free CFMLCommandBox : Free CFML
CommandBox : Free CFML
Ortus Solutions, Corp
 
Advanced caching techniques with ehcache, big memory, terracotta, and coldfusion
Advanced caching techniques with ehcache, big memory, terracotta, and coldfusionAdvanced caching techniques with ehcache, big memory, terracotta, and coldfusion
Advanced caching techniques with ehcache, big memory, terracotta, and coldfusion
ColdFusionConference
 

Viewers also liked (6)

Testing For Success
Testing For SuccessTesting For Success
Testing For Success
 
Make It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version ControlMake It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version Control
 
Using NoSQL MongoDB with ColdFusion
Using NoSQL MongoDB with ColdFusionUsing NoSQL MongoDB with ColdFusion
Using NoSQL MongoDB with ColdFusion
 
ITB2016 - NoSQL with mongodb and ColdFusion (CFML)
ITB2016 - NoSQL with mongodb and ColdFusion (CFML)ITB2016 - NoSQL with mongodb and ColdFusion (CFML)
ITB2016 - NoSQL with mongodb and ColdFusion (CFML)
 
CommandBox : Free CFML
CommandBox : Free CFMLCommandBox : Free CFML
CommandBox : Free CFML
 
Advanced caching techniques with ehcache, big memory, terracotta, and coldfusion
Advanced caching techniques with ehcache, big memory, terracotta, and coldfusionAdvanced caching techniques with ehcache, big memory, terracotta, and coldfusion
Advanced caching techniques with ehcache, big memory, terracotta, and coldfusion
 

Similar to CFWheels - Pragmatic, Beautiful Code

Intro to ColdBox MVC at Japan CFUG
Intro to ColdBox MVC at Japan CFUGIntro to ColdBox MVC at Japan CFUG
Intro to ColdBox MVC at Japan CFUG
Ortus Solutions, Corp
 
ZZ BC#7 asp.net mvc practice and guideline by NineMvp
ZZ BC#7 asp.net mvc practice and guideline by NineMvpZZ BC#7 asp.net mvc practice and guideline by NineMvp
ZZ BC#7 asp.net mvc practice and guideline by NineMvp
Chalermpon Areepong
 
AngularJS One Day Workshop
AngularJS One Day WorkshopAngularJS One Day Workshop
AngularJS One Day Workshop
Shyam Seshadri
 
Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3
Drupalcon Paris
 
FlexDeploy Product Technical Overview
FlexDeploy Product Technical OverviewFlexDeploy Product Technical Overview
FlexDeploy Product Technical Overview
Dalibor Blazevic
 
Integrating AngularJS with Drupal 7
Integrating AngularJS with Drupal 7Integrating AngularJS with Drupal 7
Integrating AngularJS with Drupal 7
andrewmriley
 
Asp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin SawantAsp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin Sawant
Nitin Sawant
 
MVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming modelMVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming model
Alex Thissen
 
Rapid application development with spring roo j-fall 2010 - baris dere
Rapid application development with spring roo   j-fall 2010 - baris dereRapid application development with spring roo   j-fall 2010 - baris dere
Rapid application development with spring roo j-fall 2010 - baris dere
Baris Dere
 
Give your little scripts big wings: Using cron in the cloud with Amazon Simp...
Give your little scripts big wings:  Using cron in the cloud with Amazon Simp...Give your little scripts big wings:  Using cron in the cloud with Amazon Simp...
Give your little scripts big wings: Using cron in the cloud with Amazon Simp...
Amazon Web Services
 
The future of web development write once, run everywhere with angular.js and ...
The future of web development write once, run everywhere with angular.js and ...The future of web development write once, run everywhere with angular.js and ...
The future of web development write once, run everywhere with angular.js and ...
Mark Roden
 
The future of web development write once, run everywhere with angular js an...
The future of web development   write once, run everywhere with angular js an...The future of web development   write once, run everywhere with angular js an...
The future of web development write once, run everywhere with angular js an...
Mark Leusink
 
Agile Secure Cloud Application Development Management
Agile Secure Cloud Application Development ManagementAgile Secure Cloud Application Development Management
Agile Secure Cloud Application Development Management
Adam Getchell
 
[Struyf] Automate Your Tasks With Azure Functions
[Struyf] Automate Your Tasks With Azure Functions[Struyf] Automate Your Tasks With Azure Functions
[Struyf] Automate Your Tasks With Azure Functions
European Collaboration Summit
 
Structured Functional Automated Web Service Testing
Structured Functional Automated Web Service TestingStructured Functional Automated Web Service Testing
Structured Functional Automated Web Service Testing
rdekleijn
 
Introduction to Flask Micro Framework
Introduction to Flask Micro FrameworkIntroduction to Flask Micro Framework
Introduction to Flask Micro Framework
Mohammad Reza Kamalifard
 
symfony_from_scratch
symfony_from_scratchsymfony_from_scratch
symfony_from_scratch
tutorialsruby
 
symfony_from_scratch
symfony_from_scratchsymfony_from_scratch
symfony_from_scratch
tutorialsruby
 
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Anupam Ranku
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
Joram Salinas
 

Similar to CFWheels - Pragmatic, Beautiful Code (20)

Intro to ColdBox MVC at Japan CFUG
Intro to ColdBox MVC at Japan CFUGIntro to ColdBox MVC at Japan CFUG
Intro to ColdBox MVC at Japan CFUG
 
ZZ BC#7 asp.net mvc practice and guideline by NineMvp
ZZ BC#7 asp.net mvc practice and guideline by NineMvpZZ BC#7 asp.net mvc practice and guideline by NineMvp
ZZ BC#7 asp.net mvc practice and guideline by NineMvp
 
AngularJS One Day Workshop
AngularJS One Day WorkshopAngularJS One Day Workshop
AngularJS One Day Workshop
 
Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3
 
FlexDeploy Product Technical Overview
FlexDeploy Product Technical OverviewFlexDeploy Product Technical Overview
FlexDeploy Product Technical Overview
 
Integrating AngularJS with Drupal 7
Integrating AngularJS with Drupal 7Integrating AngularJS with Drupal 7
Integrating AngularJS with Drupal 7
 
Asp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin SawantAsp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin Sawant
 
MVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming modelMVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming model
 
Rapid application development with spring roo j-fall 2010 - baris dere
Rapid application development with spring roo   j-fall 2010 - baris dereRapid application development with spring roo   j-fall 2010 - baris dere
Rapid application development with spring roo j-fall 2010 - baris dere
 
Give your little scripts big wings: Using cron in the cloud with Amazon Simp...
Give your little scripts big wings:  Using cron in the cloud with Amazon Simp...Give your little scripts big wings:  Using cron in the cloud with Amazon Simp...
Give your little scripts big wings: Using cron in the cloud with Amazon Simp...
 
The future of web development write once, run everywhere with angular.js and ...
The future of web development write once, run everywhere with angular.js and ...The future of web development write once, run everywhere with angular.js and ...
The future of web development write once, run everywhere with angular.js and ...
 
The future of web development write once, run everywhere with angular js an...
The future of web development   write once, run everywhere with angular js an...The future of web development   write once, run everywhere with angular js an...
The future of web development write once, run everywhere with angular js an...
 
Agile Secure Cloud Application Development Management
Agile Secure Cloud Application Development ManagementAgile Secure Cloud Application Development Management
Agile Secure Cloud Application Development Management
 
[Struyf] Automate Your Tasks With Azure Functions
[Struyf] Automate Your Tasks With Azure Functions[Struyf] Automate Your Tasks With Azure Functions
[Struyf] Automate Your Tasks With Azure Functions
 
Structured Functional Automated Web Service Testing
Structured Functional Automated Web Service TestingStructured Functional Automated Web Service Testing
Structured Functional Automated Web Service Testing
 
Introduction to Flask Micro Framework
Introduction to Flask Micro FrameworkIntroduction to Flask Micro Framework
Introduction to Flask Micro Framework
 
symfony_from_scratch
symfony_from_scratchsymfony_from_scratch
symfony_from_scratch
 
symfony_from_scratch
symfony_from_scratchsymfony_from_scratch
symfony_from_scratch
 
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 

Recently uploaded

BLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALL
BLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALLBLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALL
BLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALL
Liveplex
 
20240705 QFM024 Irresponsible AI Reading List June 2024
20240705 QFM024 Irresponsible AI Reading List June 202420240705 QFM024 Irresponsible AI Reading List June 2024
20240705 QFM024 Irresponsible AI Reading List June 2024
Matthew Sinclair
 
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
Toru Tamaki
 
How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx
Adam Dunkels
 
DealBook of Ukraine: 2024 edition
DealBook of Ukraine: 2024 editionDealBook of Ukraine: 2024 edition
DealBook of Ukraine: 2024 edition
Yevgen Sysoyev
 
Advanced Techniques for Cyber Security Analysis and Anomaly Detection
Advanced Techniques for Cyber Security Analysis and Anomaly DetectionAdvanced Techniques for Cyber Security Analysis and Anomaly Detection
Advanced Techniques for Cyber Security Analysis and Anomaly Detection
Bert Blevins
 
Quality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of TimeQuality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of Time
Aurora Consulting
 
The Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive ComputingThe Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive Computing
Larry Smarr
 
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdfINDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
jackson110191
 
Choose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presenceChoose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presence
rajancomputerfbd
 
The Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU CampusesThe Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU Campuses
Larry Smarr
 
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - MydbopsScaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Mydbops
 
Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...
BookNet Canada
 
What’s New in Teams Calling, Meetings and Devices May 2024
What’s New in Teams Calling, Meetings and Devices May 2024What’s New in Teams Calling, Meetings and Devices May 2024
What’s New in Teams Calling, Meetings and Devices May 2024
Stephanie Beckett
 
20240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 202420240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 2024
Matthew Sinclair
 
Observability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetryObservability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetry
Eric D. Schabell
 
Best Programming Language for Civil Engineers
Best Programming Language for Civil EngineersBest Programming Language for Civil Engineers
Best Programming Language for Civil Engineers
Awais Yaseen
 
Calgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptxCalgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptx
ishalveerrandhawa1
 
find out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challengesfind out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challenges
huseindihon
 
Coordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar SlidesCoordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar Slides
Safe Software
 

Recently uploaded (20)

BLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALL
BLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALLBLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALL
BLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALL
 
20240705 QFM024 Irresponsible AI Reading List June 2024
20240705 QFM024 Irresponsible AI Reading List June 202420240705 QFM024 Irresponsible AI Reading List June 2024
20240705 QFM024 Irresponsible AI Reading List June 2024
 
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
 
How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx
 
DealBook of Ukraine: 2024 edition
DealBook of Ukraine: 2024 editionDealBook of Ukraine: 2024 edition
DealBook of Ukraine: 2024 edition
 
Advanced Techniques for Cyber Security Analysis and Anomaly Detection
Advanced Techniques for Cyber Security Analysis and Anomaly DetectionAdvanced Techniques for Cyber Security Analysis and Anomaly Detection
Advanced Techniques for Cyber Security Analysis and Anomaly Detection
 
Quality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of TimeQuality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of Time
 
The Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive ComputingThe Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive Computing
 
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdfINDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
 
Choose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presenceChoose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presence
 
The Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU CampusesThe Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU Campuses
 
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - MydbopsScaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
 
Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...
 
What’s New in Teams Calling, Meetings and Devices May 2024
What’s New in Teams Calling, Meetings and Devices May 2024What’s New in Teams Calling, Meetings and Devices May 2024
What’s New in Teams Calling, Meetings and Devices May 2024
 
20240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 202420240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 2024
 
Observability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetryObservability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetry
 
Best Programming Language for Civil Engineers
Best Programming Language for Civil EngineersBest Programming Language for Civil Engineers
Best Programming Language for Civil Engineers
 
Calgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptxCalgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptx
 
find out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challengesfind out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challenges
 
Coordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar SlidesCoordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar Slides
 

CFWheels - Pragmatic, Beautiful Code

  • 1. CFWheels Pragmatic, Beautiful code Indy Nagpal Straker Software Melbourne, November 2010
  • 2. A bit about me •  CTO, Straker Software, New Zealand •  Been doing CF (and Flex) for a while •  Cloud-based CF Using Railo •  In love with Ruby (the language) & Rails – Was in love with Groovy (still am, I think) •  nagpals.com/blog
  • 4. Agile •  Early, continuous delivery of software •  Welcome changing requirements •  Deliver working software frequently •  Working software = progress •  Technical excellence and good design •  Simplicity is essential – work not done
  • 5. “There comes a time in the history of every project when it becomes necessary to shoot the engineers and begin production.”
  • 6. Need •  Quickly build and deploy database-driven web apps •  Rapid iterations in a testable fashion •  Easy for multiple developers to understand •  Working app is more important than configuring the app
  • 7. Search… •  Tried lots of frameworks/methodologies •  Ruby on Rails addressed most issues •  Learn another language and framework •  Defeats the whole purpose •  Enter, CFWheels…
  • 8. What is CFWheels •  Framework inspired by Ruby on Rails •  Simple organization system •  Suited for typical, database-driven web applications •  A couple of years’ old – fairly mature
  • 9. Convention over configuration •  Possibly the single most important thing •  Mostly convention, minor configuration •  Easy to – turn on – tune in – drop out
  • 11. Intuitive Code Structure •  View –  Responsible for display and user interaction –  Receive data from controller •  Controller –  Process requests from view –  Get/process data from model –  Make data available to the view •  Model –  Interacts with the database layer –  Responsible for validation –  Other methods to process/message data
  • 12. Convention - URLs •  URLs mapped to controllers/models/views http://blog/posts/edit/1 Controller: Posts Model: Post Action: Edit Key: 1
  • 13. View – http://blog/posts/ /views/posts/index.cfm <cfparam name="posts"> <ul> <cfoutput query="posts"> <li> #linkTo( text = "#posts.title#", action = "edit", key = post.id, title = "Edit #posts.name#" )# </li> </cfoutput> </ul>
  • 14. Controller – http://blog/posts/ /controllers/Posts.cfc <cfcomponent extends="Controller"> <cfscript> function index(){ posts = model("post").findAll(order="createdAt") } </cfscript> </cfcomponent
  • 15. Model – http://blog/posts/ /models/Post.cfc <cfcomponent extends="Model"> <cfscript> function init(){ belongsTo("author") hasMany("comments") validatesLengthOf( properties = "title", minimum = 10, maximum = 255) } </cfscript> </cfcomponent>
  • 16. Convention – Files & Database •  Place in appropriate folders – MVC •  Plural database names, singular model names – DB Table: posts – Model: Post.cfc •  Database fields: id, createdat, updatedat
  • 17. Built-in ORM •  Simple and elegant •  All major databases supported •  Almost no setup required – baked in •  CRUD instantly available via models/plugin •  Finding data using “finders” –  findOne(), findAll(), findByKey()…
  • 18. Associations models/Post.cfc <cfcomponent extends="Model">
 <cfscript> function init(){ belongsTo("author") } </cfscript>
 </cfcomponent> models/Author.cfc <cfcomponent extends="Model">
 <cfscript> function init(){ hasMany("posts") } </cfscript>
 </cfcomponent> <cfscript> posts = model("post").findAll(include="author") author = model("author").findOneByKey(key=params.key,include="posts") </cfscript>
  • 19. Dynamic Finders •  Dynamic finders are magical model("user").findOne(where="username='bob' and password='pass'") rewritten as model("user").findOneByUsernameAndPassword("bob,pass”)
  • 20. URLs and Routing •  Beautiful URLs –  http://blog/a-good-url •  Powerful routing mechanism <cfset addRoute( name = "showPost", 
 pattern = "/[key]”,
 controller = "Posts",
 action = "show")> •  Can be turned REST-full
  • 21. Multiple response formats •  http://blog/posts •  http://blog/posts.xml •  http://blog/posts.json •  http://blog/posts.csv •  http://blog/posts.pdf
  • 22. Common tasks done •  Adding timestamps •  Flashing messages •  Pagination •  Sending multi-part emails •  Redirecting users
  • 23. Lots of helper functions •  Views selectBox() linkTo() timeAgoInWords() paginationLinks() titleize() pluralize() •  Model validatePresenceOf() findAll() findOneByKey() afterSave() •  Controller flash() isGet() sendMail()
  • 24. Plugins •  Neat architecture to add/override functionality •  Extremely useful – Scaffold –generate CRUD application – DBMigrate – Add/edit database structure – Remote Form Helpers – Ajax with forms – Localizer – Localizing an application
  • 25. Baked in testing •  Ships with RocketUnit <cfcomponent extends="tests.Test"> <cfscript> function test_1_get_timezones(){ qTimezone = model("Timezone").getTimezones() assert("isQuery(qTimezone) ") assert("qTimezone.recordcount eq 56") } </cfscript> </cfcomponent>
  • 26. Environments •  Different setup for applications based on stages of development – Design, Development, Production, Testing, Maintenance •  Differ in terms of caching, error-handling •  Switch environments via config/url
  • 27. Docs/Support •  Very helpful docs at cfwheels.org •  Active and supportive mailing list •  Quite a few screencasts •  Direct knowledge transfer from Ruby on Rails books/docs (e.g., Head First Rails) •  Bunch of blogs
  • 28. IDE Support •  Eclipse, CFBuilder – Syntax Dictionary •  Textmate – Bundle •  Coda – Lacking, but works by adding Clips
  • 29. Beauty •  Simple code organization and flow •  Easy to understand code – eyeballing code •  Common tasks done with minimal code •  Pretty URLs •  Almost zero configuration, with power to configure as much as needed
  • 30. Pragmatic •  Focus on simple code that solves issues •  Trades pure OO for simplicity and structure •  Easy to not use the framework if needed •  Common web application problems already solved – why reinvent the wheel(s)!
  • 31. Wrap up •  Evaluate if you need a ‘framework’ •  Learn URL rewrites (Apache, IIS) •  Dabble with Ruby on Rails •  cfscript = succinct code •  Worth trying out just to see how problems can be solved in a different manner