Matt Gifford aka coldfumonkeh | Consultant Developer
View Github Profile


Into The Box 2015 Notes

May 12, 2015

Into the Box 2015

Monkeh Works are speaking at (and attending the rest of) Into The Box in Minneapolis and will be posting notes of sessions attended throughout the day.

Thanks to Ortus Solutions for organising this great event and for all of the sponsors for, well, sponsoring it.

This is the brain dump of notes taken throughout the sessions attended.

Make of them what you will.


NoSQL for you and me

Presented by Brad Wood and Curt Gratz

  • NoSQL is just a buzz word. No standards involved.
  • Characteristics:
    • non-relational
    • open-source (some of them are, anyway)
    • cluster-friendly (some of them are, anyway)
    • schema less - (How can you have data without a schema?)
  • Types:
    • key/value pairs
    • document databases
    • column databases
    • graph databases
      • great for storing social media-type data (think Facebook Graph data)
  • CAP Theorem (pick two from these)
    • Consistency
    • Availability
    • Partition Tolerance
  • No More ACID
    • Atomicity - all or nothing (transactions)
    • Consistency - data is never violated (constraints, validation etc)
    • Isolation - operations must not see data from other non-finished operations (locks)
    • Durability - state of data is persisted when operation finishes (server crash protection)
  • Normalisation
    • Less data duplication
    • Less storage space
    • Higher data consistency / integrity
    • Easy to query
    • Updates are EASY
  • Denormalisation
    • Minimize the need for joins
    • Reduce the number of indexes
    • Reduce the number of relationships
    • Updates are harder (slower)
  • Making a mental shift from relational to NoSQL
    • In SQL we tend to want to avoid hitting the database as much as possible. We know it is costly when tying up connection pools and overloading DB servers.
    • Denormalisation takes getting used to.
    • Data integrity
    • Schema changes are easy

Code demo from Brad using CommandBox and CFCouchbase SDK (CFCouchbase SDK on Github)

  • Lucee extension to provide Couchbase Server (and additional caching). Free trial version or paid / commercial fully-open version.

Crash Course in Ionic + AngularJS

Presented by Nolan Erck

  • Single Page Applications with Angular.js
    • mydomain.com/#/contact
    • mydomain.com/#/products
    • instead of contant.html, products.html etc
    • routed through index.html via internal routing
    • whole site downloaded at once, then accessed via the browser cache
    • only new data is fetched from the server
  • Angular.js is:
    • MVC framework for building JS SPAs
    • include one .js file, add directive to your HTML and you’re done
    • includes:
      • D.I.
      • routing
      • 2-way data binding
      • and much more…
  • Getting Started
    • angularjs.org (and click download)
    • can get from NPM and bower too
    • <script src-"angular.js"></script>
    • html ng-app attribute
  • What is MVC?
    • Model View Controller
    • Design Pattern
    • Splits your app into three logical sections
      • Model - data and related logic
      • View - the visible / viewable aspects
      • Controller - determines what happens next in the app. May include business logic too.
  • Getting data via AJAX
    • Could get data from anywhere (Angular doesnt care)
    • $http.get('todo.json').success(function (data) { // do something })
  • $scope
    • used to persist data for the view (the data bus between the model and the view)
    • think of it as the RC scope in ContentBox or FW/1
  • Custom Directives
    • custom tags written in Angular JS
      • <my-custom-widget>
    • works like regular HTML tags
    • Similar to Polymer
  • Very brief overview on basic Angular.js features (above)
  • Ionic overview
    • mobile specific
    • Cordova / Phonegap bridge using Angular.js
    • Built on Angular’s directives and services provides powerful U.I. for mobile layouts as well as Angular data management and Cordova CLI integration.
    • Performance ‘obsessed’
      • minimal DOM manipulation
      • removed 300ms tap delay
    • Need node.js, Ionic packages and Cordova packages
    • If building locally you need SDKs installed and in place (or use PhoneGap Build)
    • Getting started
      • Ionic documentation
      • ionic start application-name
      • ionic start application-name [optional default theme]
      • Generates all files needed to start an app (skeleton framework)
      • ionic serve --lab loads up the project into a Chrome emulator that provides auto-reloading after file change
    • ion-* tags
      • Angular directives under the hood
  • Need to install SDKs for each platform (iOS, Android etc)
    • Takes a little more time
    • Android isnt super intuitive (it can be a PITA <- monkeh note)

Check out the http://ionicframework.com/ and https://angularjs.org/


Winning with Vagrant, Puppet and Chef

Presented by Matt Gifford


Killing Shark-Riding Dinosaurs with ORM

Presented by Joel Watson

  • Shark-riding dinosaurs
    • are fed on bad (or no planning)
    • are attracted to the smell of code patches used to hold together a failed data model
    • are hard to kill because they are armed to the teeth and have self-destruct mechanisms
    • they are usually bigger than you
  • Top Ten tips for ORM sanity:
    1. OO Modeling is key
      • ORM relationship modeling is key
      • OO is required
      • UML is your best friend
      • STOP THINKING ABOUT DATA
      • YOU ARE NOT MODELING A DATABASE
    2. Engine defaults are not great
      • Dont use CF engine defaults such as:
      • FlushAtRequestEnd (send to database)
      • Session management (transactions)
      • Caching
    3. Understand Hibernate Session
      • Similar name, but not the same as session scope
      • A transitory space
      • A caching layer
      • You need to be the one controlling when stuff gets sent to the database
      • Secondary caching…
    4. Transaction Demarcation
      • Transactions demarcate SQL boundaries
      • Important for ORM and SQL
      • Pretty much ZERO communication to DB should happen without it
    5. Lazy Loading is the key
      • Try your app without it and watch the fail
      • Do you have performance? Don’t use lazy loading
      • Types of laziness:
      • true = only when you ask for stuff
      • extra = load proxy objects with primary keys
      • proxy = load a proxy object * fetch=join for single query performance win * batchsize: kind of like pagination to keep the size down
    6. Avoid bi-directional
      • use with caution, and only if you know what you’re getting into
      • can cause serious headaches for complex relationships and scenarios
      • only use it if you need it
      • if you DO need it, provide some support for handling bi-directional linkage and unlinkage
    7. Don’t store entities in scopes!
      • if relationships aren’t lazy they will fail
      • Hibernate session doesnt know about your scope (nor does it care)
      • if you have to put something from your entity in scope, use it’s id and then load it faster
    8. Index like a boss
      • Failing to index is easily the #1 performance problem
    9. Caching is your friend
      • Don’t cache EVERYTHING, develop a strategy instead
      • Use distribute caching for bonus points:
      • ehcache, couchbase etc
    10. OO Modeling is KEY
      • SO important it needs to be mentioned twice.
  • Available ORM options for ColdBox applications: box install cborm
  • Base ORM service
    • Service layer for any entity
    • OO querying, caching, transactions
    • Dynamic finders, getters, counters
    • Object metadata & session management
    • Exposes more features from Hibernate
  • Virtual / Concrete ORM Services
    • Extends Base ORM Services
    • Roots itself to a single entity (less typing)
  • Active Entity
    • Active record pattern
    • Validation integration
    • DI is available
  • Base ORM Service comes with:
    • entity population via XML, JSON, queries, structs
    • compose relationships from simple value
    • Null support
    • exclude/include fields
    • server-side validation
  • Criteria Builder
    • CF ORM only gets you so far
    • entityLoad() has limited features
    • default result set is ALL the entities (much slower)
    • complex relationships are HARD to query
    • you still build SQL/HQL strings by hand? Use the Criteria Builder.
    • Criteria Builder..
      • is a programmatic DSL builder
      • has a super-rich set of criteria
      • includes a SQL inspector that can tell you what the generated SQL statement will look like

Migrating legacy applications to ColdBox MVC

Presented by Scott Caldwell

  • If a view file exists, it can be called without a handler
  • handler / event are implicitly created
  • view doesnt need to know anything about ColdBox
  • Drop existing application into the views directory and it would* run (*slight modifications may be necessary)

Must-Dos

Making URLs compatible (index.cfm)

  • Change from /user/account.cfm to /index.cm/user/account
  • NOTE .cfm extensions is no longer necessary but is permitted
  • enable SES URL setting in ColdBox; possibly use web server rewrite rules too

Deal with Application.cfc/cfm from your legacy application

  • ColdBox is now the application
  • Settings, environment variables and other magic must find a new home
    • use ColdBox settings and environments
  • Datasources, mappings etc can be moved to ColdBox’s Application.cfc

Routing

  • ColdBox auto-generates (implicitly dispatches) handlers and routes for most cases
  • You will need custom routes for 2+ deep directories
    • addroute(pattern="/ajax/tags/:action", handler="ajax/tags");
  • use CLI tools to get a list for you (don’t miss any)

cfincludes, createObjects etc.. paths will need to change

  • prepend all cfinclude templates values with /views/
  • same with objects: myObj = createObject('component', 'views.cfc.myObject');

Should-Dos

CFC invocation

  • createObject()should change to getModel()
  • Use WireBox inside of model objects
  • Consider how to handle the init() call, if applicable
    • Use WireBox

Move settings and environmental settings to ColdBox.cfc

  • ColdBox has great settings and environment management. Use them.
  • Switch application.mySetting() to getSetting('mySetting')

Utilize Layouts

  • Assign layouts to views in ColdBox.cfc
    • empty layout
  • control multiple layouts via ColdBox.cfc
  • Special cases:
    • blank layout for ajax responses

Could-Dos

  • Move static assets to /includes directory
  • Move CFCs to /models
  • Utilize Security interceptor
  • Configure WireBox for models
  • Use RC scope instead of form / url

Going Forward

  • New development can be ‘ColdBoxy’
  • Refactor legacy code to be MVC using models, handlers and views
  • Tighter integration with ColdBox offerings (eg LogBox, ForgeBox items, etc)

Finally…

  • Lay as much groundwork as you can, but get it out of the door
  • Learn regex. Will help you with search and replace actions
  • Use a build process, don’t just rely on source control
    • It won’t be as simple as a merge as you will have moved A LOT of files and made a lot of changes
    • It depends how long you think the refactor process will take

Package Management and Automation with CommandBox

Presented by Brad Wood

http://ortus.gitbooks.io

Lots of demos of package management installing from ForgeBox through the CLI.

Get books from link above :)


Powering AngularJS With RESTFul services

Presented by Curt Gratz and Nathaniel Francis


Latest Blog Posts

Jul 16, 2020
Github Actions with CommandBox and TestBox
Read More
Jul 9, 2020
Azure pipelines with CommandBox and TestBox
Read More
Dec 23, 2019
CFML content moderation detection component library
Read More