SlideShare a Scribd company logo
1 of 30
Download to read offline
ColdFusion Summit 2016
Bringing Order to the Chaos:
Take the MVC Plunge
Carl Von Stetten / @cfvonner
10/11/2016 Carl Von Stetten / @cfvonner 2
About Me
• GIS Analyst for Central Contra Costa Sanitary District (www.centralsan.org)
• Work with ColdFusion since 2002 (CF 4.5)
• Lots of spatial and non-spatial data modeling, data management, intranet application
development
• Tools I Use:
• ColdFusion, JavaScript (incl. jQuery & Bootstrap), Python, Microsoft SQL Server,Esri ArcGIS
Desktop and Server, Geocortex, Safe FME (spatial ETLs), etc…
• Manager of Bay Area ColdFusion User Group (BACFUG)– on hiatus
• Adobe Community Professional for ColdFusion
• Married 24 years, two adult children
• Unreformed DIY remodeler
• Passionate about craft beer! (should become obvious in a few minutes)
10/11/2016 Carl Von Stetten / @cfvonner 3
Agenda
• Why am I talking about MVC?
• Prerequisites for this talk
• Brief review of procedural applications
• Some code
• Introduction to Model-View-Controller concept
• Some more code
• Review pros/cons of MVC
10/11/2016 Carl Von Stetten / @cfvonner 4
A little personal history…
• Writing/maintaining procedural ColdFusion apps since 2002
• Mostly .cfm files,
• Custom tags
• Some components (.cfcs)
• Started a complete overhaul of our intranet map portal this spring
• Rewrite ColdFusion portion from scratch
• “We’re going to do it right” = go MVC
• Working prototype within 3 weeks
10/11/2016 Carl Von Stetten / @cfvonner 5
Why am I speaking?
Success
Feeling
Invincible
Submit
Topic
Get
Accepted
Terror
10/11/2016 Carl Von Stetten / @cfvonner 6
What do I need to know?
• CFML language (syntax, functions/tags, etc.)
• Basic understanding of components
• How are they structured
• How do I use them
• CreateObject()
• new
• CFInvoke
• CFObject
• ColdFusion request cycle
• Also helpful:
• CFScript syntax (similar to JavaScript syntax)
10/11/2016 Carl Von Stetten / @cfvonner 7
What is a procedural application?
• CFM page for each URL in app
• Pages execute from top to bottom
• Typically 100’s of lines of code per page
• Mix of business logic and display code
10/11/2016 Carl Von Stetten / @cfvonner 8
Disclaimer
“The code you about to see is simplified for clarity. It does not necessarily
represent best practices, does not include security measures, and does not
include user input validation/sanitation.” - Me
10/11/2016 Carl Von Stetten / @cfvonner 9
What does a procedural app look like?
10/11/2016 Carl Von Stetten / @cfvonner 10
Downsides of procedural code
• Increasingly hard to maintain, especially as app evolves
• Hard to distribute work to teams
• Potentially lots of code duplication
• Violating DRY principle
• Can’t build an API from the business logic
• Intertwined with display code
10/11/2016 Carl Von Stetten / @cfvonner 11
Is there a better way?
• YES!
• MVC
• (you knew I was going to say that)
10/11/2016 Carl Von Stetten / @cfvonner 12
What is MVC?
• Model-View-Controller design
pattern
• Separates concerns (business logic
vs. view logic)
• Common design pattern in OO
languages
• Usually leverage MVC framework
• Rails for Ruby
• Django for Python
• ASP.NetMVC
• Express/Sails for Node.js
• Laravel/CakePHP for PHP
10/11/2016 Carl Von Stetten / @cfvonner 13
Model Layer
• Business logic
• Database interactions (CRUD)
• External web service access
• Validation
• Helper services
• Should not know anything about
the framework (including
controllers and views)
• Responds to requests from the
controller
10/11/2016 Carl Von Stetten / @cfvonner 14
View Layer
• User Interface
• HTML/CSS/JavaScript
• Minimal Server-Side logic for
display control
• NO Business logic!!!
• NO SQL code here!!!
• Should not know anything about
the model
• Relies on Controller to get data
10/11/2016 Carl Von Stetten / @cfvonner 15
• Controls the flow of the application
• Examines each incoming request
(URL/Form variables or path)
• Calls relevant business logic (model
objects/components)
• Passes results from model to view
layer
• Minimal validation
• Short controller functions
10/11/2016 Carl Von Stetten / @cfvonner 16
Controller Layer
MVC in ColdFusion
• MVC can be done without a framework
• Unless your hobby is reinventing the wheel, why would you?
• Frameworks offer lots of functionality you don’t have to reinvent
• Dependency Injection/Inversion of control
• Stay in this room for NolanErck: Dependency Injection: Why is it awesome and why should I
care?
• URL Routes
• Layout/view templating
• Data Rendering (JSON, XML, text, custom)
• Modules
• Frameworks often improve code organization
10/11/2016 Carl Von Stetten / @cfvonner 17
Modern MVC Frameworks
• Framework-One (FW/1)
• ColdBox
• Some older frameworks still in use
• Model-Glue
• Mach II
• Fusebox
• CFWheels
• FarCry Core
10/11/2016 Carl Von Stetten / @cfvonner 18
What is Framework-One (FW/1)?
• Created by Sean Corfield
• Version 4.0 recently released
• Small, lightweight,convention-over-configuration MVC framework
• MVC portion is one file, one.cfc (130KB)
• Two related files:
• ioc.cfc– dependency injection/inversion of control
• aop.cfc – aspect-oriented programming
10/11/2016 Carl Von Stetten / @cfvonner 19
What is
“convention over configuration”?
• Structure your application folders per recommendations and the
framework figures out the rest for you
• You only need to specify configuration settings if you:
• Need to override defaults
• Deviate from the recommended structure
• Deviate from the file naming conventions
10/11/2016 Carl Von Stetten / @cfvonner 20
What the heck is “rc”?
• rc variable = alias for request context, or request.context
• Sort of another scope (like application, session, request, etc.)
• Mechanism for passing data between framework, controller, and views
• FW/1 automatically populates rc with URL and FORM variables
• You write controller methods to insert anything else your views need
10/11/2016 Carl Von Stetten / @cfvonner 21
What does a FW/1 MVC app look like?
10/11/2016 Carl Von Stetten / @cfvonner 22
Pros
• Promotes DRY (code reuse)
• Assists team efforts
• Different parts of model,
controllers, views can be worked
on simultaneously
• Common pattern/terminology
• Enforces better code
organization
Cons
• Have to learn some new
concepts, even if excellent
procedural programmer
• Might seem to end up with more
files to manage
• But the files will be more focused
and on-point
MVC - the good and bad
10/11/2016 Carl Von Stetten / @cfvonner 23
Migrating Legacy Apps
• Don’t have to “eat the elephant” all at once
• Choose logical sections/modules of an app to migrate OR start new work in
MVC pattern
• MVC code can coexist with procedural code
• With combination of configuration settings and web server rewrite rules
10/11/2016 Carl Von Stetten / @cfvonner 24
Key takeaways
• MVC isn’t as hard as it seems
• It will make application code maintenance easier for the future
10/11/2016 Carl Von Stetten / @cfvonner 25
Learn more at ColdFusion Summit!
• Directly related:
• Dependency Injection: Why is it awesome and why should I care? – Nolan Erck
• Banyan B – 11:30am-12:30pm
• Easier development environments:
• Instant ColdFusion Servers with Vagrant – Trip Ward
• Banyan B – 1:30pm-2:30pm
• Herding Cats: A new way to manage all your Adobe servers on one dev machine –
Brad Wood
• Jasmine F – 4pm-5pm
10/11/2016 Carl Von Stetten / @cfvonner 26
MVC framework resources
• Documentation & Downloads
• Framework-One
• Docs: http://framework-one.github.io/
• Download:
https://github.com/framework-one/fw1
• ColdBox - https://www.coldbox.org/
• Discussion Groups
• Framework-One Google Group
• ColdBox Google Group
• Real-Time Assistance
• Slack Team
• FW/1 channel
• Box-products channel
10/11/2016 Carl Von Stetten / @cfvonner 27
• Books:
Some more resources
10/11/2016 Carl Von Stetten / @cfvonner 28
• Get Help:
• Adobe ColdFusion forum:
• http://adobe.ly/2eg63QJ
• StackOverflow.com
• Documentation:
• Adobe ColdFusion docs:
• http://adobe.ly/2eg7nTD
• Community docs:
• http://cfdocs.org/
• Links back to ACF and Lucee docs
• Great CFScript info!!
• Real-Time Assistance
• CFML Slack Team
Thank you!!!
• Questions???
• Contact me:
• Email: carl.vonstetten1@gmail.com
• Twitter: @cfvonner
• GitHub: cfvonner
• CFML Team on Slack: @cfvonner
• Don’t forget to fill out session evaluation
• You can do it in the Mobile App on iOS and Android!
• Code/slides will be on Github: https://github.com/cfvonner/CFSummit2016-MVC
10/11/2016 Carl Von Stetten / @cfvonner 29
Thank You!

More Related Content

What's hot

C:\fakepath\alpha jax.codecamp2010
C:\fakepath\alpha jax.codecamp2010C:\fakepath\alpha jax.codecamp2010
C:\fakepath\alpha jax.codecamp2010
Marker Studio
 

What's hot (20)

Tarabica 2019 - Migration from ASP.NET MVC to ASP.NET Core
Tarabica 2019 - Migration from ASP.NET MVC to ASP.NET CoreTarabica 2019 - Migration from ASP.NET MVC to ASP.NET Core
Tarabica 2019 - Migration from ASP.NET MVC to ASP.NET Core
 
Sitecore mvc
Sitecore mvcSitecore mvc
Sitecore mvc
 
Yasgui: not just another sparql gui
Yasgui: not just another sparql guiYasgui: not just another sparql gui
Yasgui: not just another sparql gui
 
Introduction to PowerShell for SharePoint Admins and Developers
Introduction to PowerShell for SharePoint Admins and DevelopersIntroduction to PowerShell for SharePoint Admins and Developers
Introduction to PowerShell for SharePoint Admins and Developers
 
ASP.NET Core 1.0 Overview
ASP.NET Core 1.0 OverviewASP.NET Core 1.0 Overview
ASP.NET Core 1.0 Overview
 
Team foundation server
Team foundation serverTeam foundation server
Team foundation server
 
Do's and don'ts for Office 365 development
Do's and don'ts for Office 365 developmentDo's and don'ts for Office 365 development
Do's and don'ts for Office 365 development
 
Migration from ASP.NET MVC to ASP.NET Core
Migration from ASP.NET MVC to ASP.NET CoreMigration from ASP.NET MVC to ASP.NET Core
Migration from ASP.NET MVC to ASP.NET Core
 
Application Lifecycle Management for Office 365 development
Application Lifecycle Management for Office 365 developmentApplication Lifecycle Management for Office 365 development
Application Lifecycle Management for Office 365 development
 
Introduction to SharePoint Framework
Introduction to SharePoint FrameworkIntroduction to SharePoint Framework
Introduction to SharePoint Framework
 
C:\fakepath\alpha jax.codecamp2010
C:\fakepath\alpha jax.codecamp2010C:\fakepath\alpha jax.codecamp2010
C:\fakepath\alpha jax.codecamp2010
 
ECS19 - Nik Charlebois - Automate the Deployment & Monitoring of SharePoint w...
ECS19 - Nik Charlebois - Automate the Deployment & Monitoring of SharePoint w...ECS19 - Nik Charlebois - Automate the Deployment & Monitoring of SharePoint w...
ECS19 - Nik Charlebois - Automate the Deployment & Monitoring of SharePoint w...
 
ASP.NET Core Unit Testing
ASP.NET Core Unit TestingASP.NET Core Unit Testing
ASP.NET Core Unit Testing
 
Apex world 2018 continuously delivering APEX
Apex world 2018 continuously delivering APEXApex world 2018 continuously delivering APEX
Apex world 2018 continuously delivering APEX
 
Chris O'Brien - Introduction to the SharePoint Framework for developers
Chris O'Brien - Introduction to the SharePoint Framework for developersChris O'Brien - Introduction to the SharePoint Framework for developers
Chris O'Brien - Introduction to the SharePoint Framework for developers
 
TestMaker Object Designer Training - Basics
TestMaker Object Designer Training - BasicsTestMaker Object Designer Training - Basics
TestMaker Object Designer Training - Basics
 
Deep dive into share point framework webparts
Deep dive into share point framework webpartsDeep dive into share point framework webparts
Deep dive into share point framework webparts
 
Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)
Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)
Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)
 
ECS 19 - Chris O'Brien - The hit list - Office 365 dev techniques you should ...
ECS 19 - Chris O'Brien - The hit list - Office 365 dev techniques you should ...ECS 19 - Chris O'Brien - The hit list - Office 365 dev techniques you should ...
ECS 19 - Chris O'Brien - The hit list - Office 365 dev techniques you should ...
 
BrightGen Spring 16 Release Webinar
BrightGen Spring 16 Release WebinarBrightGen Spring 16 Release Webinar
BrightGen Spring 16 Release Webinar
 

Similar to ColdFusion Summit 2016 - Bringing Order to the Chaos: Take the MVC Plunge

The Need For Speed - NEBytes
The Need For Speed - NEBytesThe Need For Speed - NEBytes
The Need For Speed - NEBytes
Phil Pursglove
 
The Need for Speed - EpiCenter 2010
The Need for Speed - EpiCenter 2010The Need for Speed - EpiCenter 2010
The Need for Speed - EpiCenter 2010
Phil Pursglove
 
Jan Egil Ring - Get started with windows power shell desired state configuration
Jan Egil Ring - Get started with windows power shell desired state configurationJan Egil Ring - Get started with windows power shell desired state configuration
Jan Egil Ring - Get started with windows power shell desired state configuration
Nordic Infrastructure Conference
 
Cloud Foundry and Microservices: A Mutualistic Symbiotic Relationship
Cloud Foundry and Microservices: A Mutualistic Symbiotic RelationshipCloud Foundry and Microservices: A Mutualistic Symbiotic Relationship
Cloud Foundry and Microservices: A Mutualistic Symbiotic Relationship
VMware Tanzu
 
Cloud Foundry and Microservices: A Mutualistic Symbiotic Relationship
Cloud Foundry and Microservices: A Mutualistic Symbiotic RelationshipCloud Foundry and Microservices: A Mutualistic Symbiotic Relationship
Cloud Foundry and Microservices: A Mutualistic Symbiotic Relationship
Matt Stine
 
Decision CAMP 2014 - Erik Marutian - Using rules-based gui framework to power...
Decision CAMP 2014 - Erik Marutian - Using rules-based gui framework to power...Decision CAMP 2014 - Erik Marutian - Using rules-based gui framework to power...
Decision CAMP 2014 - Erik Marutian - Using rules-based gui framework to power...
Decision CAMP
 
The Need For Speed - NxtGen Cambridge
The Need For Speed - NxtGen CambridgeThe Need For Speed - NxtGen Cambridge
The Need For Speed - NxtGen Cambridge
Phil Pursglove
 

Similar to ColdFusion Summit 2016 - Bringing Order to the Chaos: Take the MVC Plunge (20)

VMworld 2013: Examining vSphere Design Through a Design Scenario
VMworld 2013: Examining vSphere Design Through a Design Scenario VMworld 2013: Examining vSphere Design Through a Design Scenario
VMworld 2013: Examining vSphere Design Through a Design Scenario
 
Twelve-Factor application pattern with Spring Framework
Twelve-Factor application pattern with Spring FrameworkTwelve-Factor application pattern with Spring Framework
Twelve-Factor application pattern with Spring Framework
 
FuelPHP - a PHP HMVC Framework by silicongulf.com
FuelPHP - a PHP HMVC Framework by silicongulf.comFuelPHP - a PHP HMVC Framework by silicongulf.com
FuelPHP - a PHP HMVC Framework by silicongulf.com
 
Lifecycle Management with SharePoint Apps and Solutions
Lifecycle Management with SharePoint Apps and SolutionsLifecycle Management with SharePoint Apps and Solutions
Lifecycle Management with SharePoint Apps and Solutions
 
Highlights from microsoft ignite 2015
Highlights from microsoft ignite 2015Highlights from microsoft ignite 2015
Highlights from microsoft ignite 2015
 
The Need For Speed - NEBytes
The Need For Speed - NEBytesThe Need For Speed - NEBytes
The Need For Speed - NEBytes
 
Mastering asp.net mvc - Dot Net Tricks
Mastering asp.net mvc - Dot Net TricksMastering asp.net mvc - Dot Net Tricks
Mastering asp.net mvc - Dot Net Tricks
 
Velocity - Edge UG
Velocity - Edge UGVelocity - Edge UG
Velocity - Edge UG
 
Mvc3 part1
Mvc3   part1Mvc3   part1
Mvc3 part1
 
Come riprogettare le attuali farm solution di share point con il nuovo modell...
Come riprogettare le attuali farm solution di share point con il nuovo modell...Come riprogettare le attuali farm solution di share point con il nuovo modell...
Come riprogettare le attuali farm solution di share point con il nuovo modell...
 
The Need for Speed - EpiCenter 2010
The Need for Speed - EpiCenter 2010The Need for Speed - EpiCenter 2010
The Need for Speed - EpiCenter 2010
 
Phil Pursglove: Velocity, the Need for Speed - epicenter 2010
Phil Pursglove: Velocity, the Need for Speed - epicenter 2010Phil Pursglove: Velocity, the Need for Speed - epicenter 2010
Phil Pursglove: Velocity, the Need for Speed - epicenter 2010
 
ALM with TFS: From the Drawing Board to the Cloud
ALM with TFS: From the Drawing Board to the CloudALM with TFS: From the Drawing Board to the Cloud
ALM with TFS: From the Drawing Board to the Cloud
 
Jan Egil Ring - Get started with windows power shell desired state configuration
Jan Egil Ring - Get started with windows power shell desired state configurationJan Egil Ring - Get started with windows power shell desired state configuration
Jan Egil Ring - Get started with windows power shell desired state configuration
 
Cloud Foundry and Microservices: A Mutualistic Symbiotic Relationship
Cloud Foundry and Microservices: A Mutualistic Symbiotic RelationshipCloud Foundry and Microservices: A Mutualistic Symbiotic Relationship
Cloud Foundry and Microservices: A Mutualistic Symbiotic Relationship
 
Cloud Foundry and Microservices: A Mutualistic Symbiotic Relationship
Cloud Foundry and Microservices: A Mutualistic Symbiotic RelationshipCloud Foundry and Microservices: A Mutualistic Symbiotic Relationship
Cloud Foundry and Microservices: A Mutualistic Symbiotic Relationship
 
ASP.NET 5
ASP.NET 5ASP.NET 5
ASP.NET 5
 
Decision CAMP 2014 - Erik Marutian - Using rules-based gui framework to power...
Decision CAMP 2014 - Erik Marutian - Using rules-based gui framework to power...Decision CAMP 2014 - Erik Marutian - Using rules-based gui framework to power...
Decision CAMP 2014 - Erik Marutian - Using rules-based gui framework to power...
 
The Need For Speed - NxtGen Cambridge
The Need For Speed - NxtGen CambridgeThe Need For Speed - NxtGen Cambridge
The Need For Speed - NxtGen Cambridge
 
Top 10 web application development frameworks 2016
Top 10 web application development frameworks 2016Top 10 web application development frameworks 2016
Top 10 web application development frameworks 2016
 

More from Carl Von Stetten

More from Carl Von Stetten (7)

How Central San uses ColdFusion to Interconnect and Manage Enterprise Infrast...
How Central San uses ColdFusion to Interconnect and Manage Enterprise Infrast...How Central San uses ColdFusion to Interconnect and Manage Enterprise Infrast...
How Central San uses ColdFusion to Interconnect and Manage Enterprise Infrast...
 
ColdFusion Summit 2016 - Powering GIS Operations with ColdFusion
ColdFusion Summit 2016 - Powering GIS Operations with ColdFusionColdFusion Summit 2016 - Powering GIS Operations with ColdFusion
ColdFusion Summit 2016 - Powering GIS Operations with ColdFusion
 
FME World Tour 2015 - Curing Migration Flu or: How I Learned to Stop Worrying...
FME World Tour 2015 - Curing Migration Flu or: How I Learned to Stop Worrying...FME World Tour 2015 - Curing Migration Flu or: How I Learned to Stop Worrying...
FME World Tour 2015 - Curing Migration Flu or: How I Learned to Stop Worrying...
 
Esri UC 2017 Water Meeting - How Central San Became a GIS-Centric Water Resou...
Esri UC 2017 Water Meeting - How Central San Became a GIS-Centric Water Resou...Esri UC 2017 Water Meeting - How Central San Became a GIS-Centric Water Resou...
Esri UC 2017 Water Meeting - How Central San Became a GIS-Centric Water Resou...
 
FME World Tour 2016 - Developing Custom Transformers to Simplify a Sanitary S...
FME World Tour 2016 - Developing Custom Transformers to Simplify a Sanitary S...FME World Tour 2016 - Developing Custom Transformers to Simplify a Sanitary S...
FME World Tour 2016 - Developing Custom Transformers to Simplify a Sanitary S...
 
FME World Tour 2017 - Blending Enterprise Data with FME Server
FME World Tour 2017 - Blending Enterprise Data with FME ServerFME World Tour 2017 - Blending Enterprise Data with FME Server
FME World Tour 2017 - Blending Enterprise Data with FME Server
 
Esri UC 2016 - Central San and the Local Government Information Model
Esri UC 2016 - Central San and the Local Government Information ModelEsri UC 2016 - Central San and the Local Government Information Model
Esri UC 2016 - Central San and the Local Government Information Model
 

Recently uploaded

Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
FIDO Alliance
 

Recently uploaded (20)

ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overview
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
How to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in PakistanHow to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in Pakistan
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
 

ColdFusion Summit 2016 - Bringing Order to the Chaos: Take the MVC Plunge

  • 2. Bringing Order to the Chaos: Take the MVC Plunge Carl Von Stetten / @cfvonner 10/11/2016 Carl Von Stetten / @cfvonner 2
  • 3. About Me • GIS Analyst for Central Contra Costa Sanitary District (www.centralsan.org) • Work with ColdFusion since 2002 (CF 4.5) • Lots of spatial and non-spatial data modeling, data management, intranet application development • Tools I Use: • ColdFusion, JavaScript (incl. jQuery & Bootstrap), Python, Microsoft SQL Server,Esri ArcGIS Desktop and Server, Geocortex, Safe FME (spatial ETLs), etc… • Manager of Bay Area ColdFusion User Group (BACFUG)– on hiatus • Adobe Community Professional for ColdFusion • Married 24 years, two adult children • Unreformed DIY remodeler • Passionate about craft beer! (should become obvious in a few minutes) 10/11/2016 Carl Von Stetten / @cfvonner 3
  • 4. Agenda • Why am I talking about MVC? • Prerequisites for this talk • Brief review of procedural applications • Some code • Introduction to Model-View-Controller concept • Some more code • Review pros/cons of MVC 10/11/2016 Carl Von Stetten / @cfvonner 4
  • 5. A little personal history… • Writing/maintaining procedural ColdFusion apps since 2002 • Mostly .cfm files, • Custom tags • Some components (.cfcs) • Started a complete overhaul of our intranet map portal this spring • Rewrite ColdFusion portion from scratch • “We’re going to do it right” = go MVC • Working prototype within 3 weeks 10/11/2016 Carl Von Stetten / @cfvonner 5
  • 6. Why am I speaking? Success Feeling Invincible Submit Topic Get Accepted Terror 10/11/2016 Carl Von Stetten / @cfvonner 6
  • 7. What do I need to know? • CFML language (syntax, functions/tags, etc.) • Basic understanding of components • How are they structured • How do I use them • CreateObject() • new • CFInvoke • CFObject • ColdFusion request cycle • Also helpful: • CFScript syntax (similar to JavaScript syntax) 10/11/2016 Carl Von Stetten / @cfvonner 7
  • 8. What is a procedural application? • CFM page for each URL in app • Pages execute from top to bottom • Typically 100’s of lines of code per page • Mix of business logic and display code 10/11/2016 Carl Von Stetten / @cfvonner 8
  • 9. Disclaimer “The code you about to see is simplified for clarity. It does not necessarily represent best practices, does not include security measures, and does not include user input validation/sanitation.” - Me 10/11/2016 Carl Von Stetten / @cfvonner 9
  • 10. What does a procedural app look like? 10/11/2016 Carl Von Stetten / @cfvonner 10
  • 11. Downsides of procedural code • Increasingly hard to maintain, especially as app evolves • Hard to distribute work to teams • Potentially lots of code duplication • Violating DRY principle • Can’t build an API from the business logic • Intertwined with display code 10/11/2016 Carl Von Stetten / @cfvonner 11
  • 12. Is there a better way? • YES! • MVC • (you knew I was going to say that) 10/11/2016 Carl Von Stetten / @cfvonner 12
  • 13. What is MVC? • Model-View-Controller design pattern • Separates concerns (business logic vs. view logic) • Common design pattern in OO languages • Usually leverage MVC framework • Rails for Ruby • Django for Python • ASP.NetMVC • Express/Sails for Node.js • Laravel/CakePHP for PHP 10/11/2016 Carl Von Stetten / @cfvonner 13
  • 14. Model Layer • Business logic • Database interactions (CRUD) • External web service access • Validation • Helper services • Should not know anything about the framework (including controllers and views) • Responds to requests from the controller 10/11/2016 Carl Von Stetten / @cfvonner 14
  • 15. View Layer • User Interface • HTML/CSS/JavaScript • Minimal Server-Side logic for display control • NO Business logic!!! • NO SQL code here!!! • Should not know anything about the model • Relies on Controller to get data 10/11/2016 Carl Von Stetten / @cfvonner 15
  • 16. • Controls the flow of the application • Examines each incoming request (URL/Form variables or path) • Calls relevant business logic (model objects/components) • Passes results from model to view layer • Minimal validation • Short controller functions 10/11/2016 Carl Von Stetten / @cfvonner 16 Controller Layer
  • 17. MVC in ColdFusion • MVC can be done without a framework • Unless your hobby is reinventing the wheel, why would you? • Frameworks offer lots of functionality you don’t have to reinvent • Dependency Injection/Inversion of control • Stay in this room for NolanErck: Dependency Injection: Why is it awesome and why should I care? • URL Routes • Layout/view templating • Data Rendering (JSON, XML, text, custom) • Modules • Frameworks often improve code organization 10/11/2016 Carl Von Stetten / @cfvonner 17
  • 18. Modern MVC Frameworks • Framework-One (FW/1) • ColdBox • Some older frameworks still in use • Model-Glue • Mach II • Fusebox • CFWheels • FarCry Core 10/11/2016 Carl Von Stetten / @cfvonner 18
  • 19. What is Framework-One (FW/1)? • Created by Sean Corfield • Version 4.0 recently released • Small, lightweight,convention-over-configuration MVC framework • MVC portion is one file, one.cfc (130KB) • Two related files: • ioc.cfc– dependency injection/inversion of control • aop.cfc – aspect-oriented programming 10/11/2016 Carl Von Stetten / @cfvonner 19
  • 20. What is “convention over configuration”? • Structure your application folders per recommendations and the framework figures out the rest for you • You only need to specify configuration settings if you: • Need to override defaults • Deviate from the recommended structure • Deviate from the file naming conventions 10/11/2016 Carl Von Stetten / @cfvonner 20
  • 21. What the heck is “rc”? • rc variable = alias for request context, or request.context • Sort of another scope (like application, session, request, etc.) • Mechanism for passing data between framework, controller, and views • FW/1 automatically populates rc with URL and FORM variables • You write controller methods to insert anything else your views need 10/11/2016 Carl Von Stetten / @cfvonner 21
  • 22. What does a FW/1 MVC app look like? 10/11/2016 Carl Von Stetten / @cfvonner 22
  • 23. Pros • Promotes DRY (code reuse) • Assists team efforts • Different parts of model, controllers, views can be worked on simultaneously • Common pattern/terminology • Enforces better code organization Cons • Have to learn some new concepts, even if excellent procedural programmer • Might seem to end up with more files to manage • But the files will be more focused and on-point MVC - the good and bad 10/11/2016 Carl Von Stetten / @cfvonner 23
  • 24. Migrating Legacy Apps • Don’t have to “eat the elephant” all at once • Choose logical sections/modules of an app to migrate OR start new work in MVC pattern • MVC code can coexist with procedural code • With combination of configuration settings and web server rewrite rules 10/11/2016 Carl Von Stetten / @cfvonner 24
  • 25. Key takeaways • MVC isn’t as hard as it seems • It will make application code maintenance easier for the future 10/11/2016 Carl Von Stetten / @cfvonner 25
  • 26. Learn more at ColdFusion Summit! • Directly related: • Dependency Injection: Why is it awesome and why should I care? – Nolan Erck • Banyan B – 11:30am-12:30pm • Easier development environments: • Instant ColdFusion Servers with Vagrant – Trip Ward • Banyan B – 1:30pm-2:30pm • Herding Cats: A new way to manage all your Adobe servers on one dev machine – Brad Wood • Jasmine F – 4pm-5pm 10/11/2016 Carl Von Stetten / @cfvonner 26
  • 27. MVC framework resources • Documentation & Downloads • Framework-One • Docs: http://framework-one.github.io/ • Download: https://github.com/framework-one/fw1 • ColdBox - https://www.coldbox.org/ • Discussion Groups • Framework-One Google Group • ColdBox Google Group • Real-Time Assistance • Slack Team • FW/1 channel • Box-products channel 10/11/2016 Carl Von Stetten / @cfvonner 27
  • 28. • Books: Some more resources 10/11/2016 Carl Von Stetten / @cfvonner 28 • Get Help: • Adobe ColdFusion forum: • http://adobe.ly/2eg63QJ • StackOverflow.com • Documentation: • Adobe ColdFusion docs: • http://adobe.ly/2eg7nTD • Community docs: • http://cfdocs.org/ • Links back to ACF and Lucee docs • Great CFScript info!! • Real-Time Assistance • CFML Slack Team
  • 29. Thank you!!! • Questions??? • Contact me: • Email: carl.vonstetten1@gmail.com • Twitter: @cfvonner • GitHub: cfvonner • CFML Team on Slack: @cfvonner • Don’t forget to fill out session evaluation • You can do it in the Mobile App on iOS and Android! • Code/slides will be on Github: https://github.com/cfvonner/CFSummit2016-MVC 10/11/2016 Carl Von Stetten / @cfvonner 29