CBDW2014 - ColdBox 4 Modules

Post on 29-Jun-2015

149 views 2 download

Tags:

description

In this session we will discuss the theory behind ColdBox 4 Modules, how and when to use them, why they are important, and how they can change how you architect your applications. We will also look at the ins about outs of creating modules and discuss some of the challenges associated with building them. So if you are new to ColdBox Modules or if you have already started down the path of modular architecture, this session if for you.

transcript

Modules

WHO AM I?

• Luis Majano - Computer Engineer

• Born in El Salvador ------------------>

• Architecture + Software Design

• CEO of Ortus Solutions

• Adobe Community Professional

• Creator of all things Box: ColdBox, ContentBox, WireBox....

AGENDA

• Monolithic Applications • What is a module? • Modular Architecture • ColdBox Modules • ColdBox 4 Features

GOLDEN RULE OF DEVELOPMENT

“Software is always bound to change”

Monolithic Apps

What do we do?

Monolithic)App)

App#Security#

Billing#

Blog#

Cart#

User#Admin#

EVOLVE TO MODULARITY

WHAT IS A MODULE?

"In structured design and data-driven design, a module is a generic term used to describe a named

and addressable group of program statements” by Craig Borysowich (Chief Technology Tactician)

!“A software module is a deployable, manageable, natively reusable, composable, stateless unit of

software that provides a concise interface to consumers.”

by Kirk Knoernschild

MODULAR ARCHITECTURE

• Break up a monolithic application • Individual logical parts that work in unison • Separation of concerns • Reusability concerns • Manageable dependencies

“As a system evolves, It’s complexity will increase unless work is done to maintain or reduce it.”

Lehman’s 2nd Law of software evolution

WHY MODULARIZE

• Represent separation of concerns • Creates logical boundaries and encapsulation • Provide behavior isolation • Improves maintainability • Improves reusability • Improves extensibility

COLDBOX MODULES

• Apply Modular Architecture • Module = A self-contained ColdBox application • Hierarchical MVC • Addressable • Composed • Dependencies • Runtime Installed • Reloaded • Unloaded

COLDBOX MODULES

Host%Application%Security%

News%

RSS%

eStore%

Admin%

Users% Comments% Posts% Billing%

COLDBOX 4 - MODULES

• Everything became a module in ColdBox 4 • CommandBox CLI & Package Management • Modules Now Can:

• Automatically maps model objects with @namespace

• Execution aliases • Improved data/setting retrievals • Inception • Bundles • Dependencies • Register ColdFusion Mappings

Anatomy of a Module

ModuleConfig.cfc

handlers

layouts

models

modules

views

Module Name(unique on disk)

box.json

box.json

MODULECONFIG.CFC

• Simple CFC • Bootstraps your module • Must exist in the root of your module folder • Has public properties • configure() for configuration • 2 callback methods: onLoad(), onUnload() • Tier-detection enabled • It’s an interceptor too!

ModuleConfig.cfc

MODULECONFIG.CFC

ModuleConfig.cfc

EXECUTION

FROM URL Event=[module:][package.]handler[.action]

SES=/module/package/handler/action !

RUNEVENT() #runEvent( ‘module:users.dashboard' )#

!

MODULE

Module

Module

Module

Module

Bundle

Module

Module

Module

Module Bundles

HOW IT WORKS?

• Download Source: https://github.com/Ortus-Solutions/ContentBox and install as a new site or a sub-folder in a site

• Create a database in your favorite database engine

• Create a datasource called “contentbox” in your CF admin that points to that database

• Hit your ContentBox install: http://localhost/index.cfm

Demo Time!

Thanks!

Go Modularize!