Mach-II at Macromedia (CFUN04)

Comments

There aren't any comments for this presentation.

Add Comment

Comments have been closed.

Transcript

no image

Slide Text

Slide Notes


Mach II at Macromedia Sean Corfield Director Architecture


Mach II at Macromedia
Sean Corfield
Director, Architecture
An introduction to Mach II and its use on macromedia.com

no notes exist for this slide

Overview


Overview
An introduction to Mach II
What Macromedia is doing with Mach II
Lessons Learned - Good & Bad

no notes exist for this slide

Introduction


Introduction
What is Mach II?
Definitions & Buzzwords
An overview of how it works
Why use Mach II?
Pros & Cons
Alternatives

no notes exist for this slide

What is Mach II i


What is Mach II? /i
"Mach-II is a web-application framework focused on easing software development and maintenance."
mach-ii.com (official Mach II website)
It's code that we can use as a foundation for our applications

no notes exist for this slide

What is Mach II ii


What is Mach II? /ii
Object-Oriented
Strict Model View Controller structure
Event-Based Implicit Invocation Architecture

no notes exist for this slide

What is Mach II iii


What is Mach II? /iii

Mach II initializes itself from an XML configuration file (mach-ii.xml). Mach II receives events (links, submits) from users, notifies the model to get data, renders views and returns HTML to the user.

What is Mach II iv


What is Mach II? /iv
Events
Generated by user (links, forms)
Generated by application code
Example
User tries to login (event=login)
Login success (event=login_ok)
Login failure (event=login_bad)

Example: User submits login form - Mach II receives the event 'login'). Mach II checks the user's credentials and if they are good, announces the 'login_ok' event; if they are not good, it announces 'login_bad'; in both cases, the new event is processed by the framework…

What is Mach II v


What is Mach II? /v
Event Handlers
Specified in XML (mach-ii.xml)
Can notify "listener" CFCs
Can render views (HTML)
Can announce new events
Can use filters to process data and affect the flow of control

An event handler is made up of commands which include notifying a listener (calling a method on a CFC), rendering views (invoking .cfm pages to generate HTML), announcing new events, invoking filters, setting event arguments, creating event mappings and so on…

What is Mach II vi


What is Mach II? /vi
A simple event handler:
<event-handler event="showHome" access="public">
<notify listener="newsManager" method="getNews" resultKey="request.news" />
<view-page name="homePage" />
</event-handler>

no notes exist for this slide

What is Mach II vii


What is Mach II? /vii
Model - ColdFusion Components
Business Domain Objects
"listeners" (for handling events)
View - CFML pages
Also layout templates, "pods" etc
Controller - Mach II
XML configuration file
Core framework files

no notes exist for this slide

What is Mach II viii


What is Mach II? /viii

no notes exist for this slide

What is Mach II ix


What is Mach II? /ix
Extensibility
Filters
CFCs that process data, announce events, change flow of control
Invoked explicitly by event handlers
Plugins
CFCs that process data, announce events, change flow of control
Invoked implicitly at key points in the event lifecycle

no notes exist for this slide

Why use Mach II i


Why use Mach II? /i
"It helps ColdFusion developers build maintainable applications by allowing them to focus separately on the independent parts of their applications: the business model, the presentation layer, the connecting logic - the flow of the application."
corfield.org (unofficial Mach II website)

no notes exist for this slide

Why use Mach II ii


Why use Mach II? /ii
Good frameworks provide a "head start"
Based on sound engineering principles
MVC design pattern
Implicit Invocation Architecture
Standardization
Common structure for applications
It supports "best practices"
Good OO design / heavy use of CFCs
Loose coupling / high cohesion

no notes exist for this slide

Why use Mach II iii


Why use Mach II? /iii
But . . .
Frameworks
Require you use their style / idiom
Constrain how you develop applications
Mach II requires you use
CFCs / OO / MVC / CFMX6.1

no notes exist for this slide

Why use Mach II iv


Why use Mach II? /iv
Alternatives?
Struts (built for Java)
http://jakarta.apache.org/struts/
Fusebox (procedural, explicit)
http://www.fusebox.org/
onTap (procedural, implicit)
http://www.turnkey.to/ontap/

Struts is a fairly complex framework originating in the Java community that some ColdFusion folks have looked to as an example. It has many good features but is also a product of many of JSP's limitations and is unnecessarily complex for many Cfers. Fusebox is the classic procedural framework for CF. Fusebox 3 was a pretty solid release and Fusebox 4 builds on that to add a number of useful new features and performance benefits. Every action is explicit in the framework. onTap is an interesting procedural framework that uses an implicit invocation style - independent files are executed automatically (implicitly) based on their location within the file system but the coding style is strictly procedural.

Macromedia amp Mach II


Macromedia & Mach II
Why did we choose Mach II?
How are we contributing to Mach II?
What applications use Mach II?

no notes exist for this slide

Why we chose Mach II


Why we chose Mach II
The macromedia.com team had
Heavy use of ColdFusion Components
Informal MVC approach in some apps
But we wanted more standards and more structure in our applications

no notes exist for this slide

Contributing to Mach II


Contributing to Mach II
Macromedia was an early adopter
Discovered bugs (& provided fixes)
Submitted enhancements (based on real-world usage scenarios)
Load testing & stability improvements
Published Mach II Development Guide

no notes exist for this slide

Applications using Mach II i


Applications using Mach II /i
We started small
Active Content Resources administrator
6 filters, 14 event handlers, 2 listeners, 7 views
Breeze Leads application
4 filters, 13 event handlers, 2 listeners, 6 views
Some internal content management applications
This proved the framework for us without taking much of a risk

Active Content Resources is a Macromedia Central application that provides information on new articles and information about the effects of the Microsoft / Eolas 906 patent dispute. The Breeze Leads application captures requests for trials and more information. The internal applications deal with a variety of content types, including management of the /go/ URL system.

Applications using Mach II ii


Applications using Mach II /ii
Product Showcase [link]
6 filters, 81 event handlers, 16 listeners, 1 plugin, 42 views
European Online Stores (HTML version) [link]
7 filters, 78 event handlers, 1 listener, 1 plugin, 45 views
14 Mach II applications in production or in development…

no notes exist for this slide

Lessons Learned


Lessons Learned
Benefits of using Mach II
Downsides to using Mach II
Freedom within the framework
Load testing & thread safety

no notes exist for this slide

Benefits of using Mach II i


Benefits of using Mach II /i
Able to leverage existing CFCs
Built an HTML version of Flash / CFC store in a short space of time
Implicit Invocation
Reduced coupling & dependencies
Easier to change application flow
Strict MVC
Separation of presentation and logic
Declarative controller (XML)

no notes exist for this slide

Benefits of using Mach II ii


Benefits of using Mach II /ii
What our engineers say
Mach II provides a head start on coding
Common code structure and very modular nature of code make it easier to maintain than ad hoc applications
Plugins and filters make it easy to extend functionality

no notes exist for this slide

Benefits of using Mach II iii


Benefits of using Mach II /iii
What our engineers say
Good MVC implementation allowing application to be built views-first or business-model-first as needed
XML controller makes incremental development & testing easier
Overall, a big win - Mach II is well-liked
"two enthusiastic thumbs up!"

no notes exist for this slide

Downsides to using Mach II


Downsides to using Mach II
What our engineers say
Lack of documentation
Debugging / Tool support
Some community tools are now appearing
Poor white space management
Improved in 1.0.9
Thread safety is big, big issue

no notes exist for this slide

Freedom within the framework i


Freedom within the framework /i
There's more than one way to do things
Filters vs Plugins
Layouts, Pods
Form handling
Request scope vs Event object
Listener style

no notes exist for this slide

Freedom within the framework ii


Freedom within the framework /ii
We used filters for
Security / login authentication
Persistence
Form handling
Localization
Caching
Omniture click-stream tracking

no notes exist for this slide

Freedom within the framework iii


Freedom within the framework /iii
We used plugins for
Application initialization / parameters
Localization
Tracing / debugging / performance analysis
Note: two approaches to localization!

no notes exist for this slide

Freedom within the framework iv


Freedom within the framework /iv
Layouts & Pods
Portal / Grid Layouts
Lots of small views, rendered to contentKey variables (pods)
Use layout template views to assemble page
Usually announce event to assemble page
CompositeView design pattern

no notes exist for this slide

Freedom within the framework v


Freedom within the framework /v
Form handling
Beaner filter
Code was written before <event-bean> command was added!
Validation filter
No custom form handling:
All basic bean-based code

no notes exist for this slide

Freedom within the framework vi


Freedom within the framework /vi
Request scope vs Event object
We mostly follow the (original) Mach II Development Guide recommendations
Mostly use a few request scope variables as the API to views
Use a few event arguments where it is clearer and more maintainable to do so
This is no longer considered best practice for Mach II!

no notes exist for this slide

Freedom within the framework vii


Freedom within the framework /vii
We have yet to choose one listener style
Some applications use a single listener as a facade for the business model
Some applications use one or two simple "manager" listeners
Some applications use a lot of small, single-function listeners

no notes exist for this slide

Load testing amp thread safety i


Load testing & thread safety /i
Mach II 1.0.9 is thread safe
Earlier versions of the framework were not!
Load testing highlighted random errors
All CFCs are stored in application scope
Need to use 'var' scope for all local declarations in all functions!

no notes exist for this slide

Load testing amp thread safety ii


Load testing & thread safety /ii
You must also 'var' declare implicitly created variables (from cfquery, cffile etc)
Example:
<cfset var results = 0 />
<cfquery name="results" …>

no notes exist for this slide

Summary


Summary
Mach II…
…is a good fit for the way we develop applications: OO, MVC
…is based on a solid software architecture: Implicit Invocation
…provides a common structure for our applications that reduces coupling, increases cohesion, eases maintenance

no notes exist for this slide

Resources


Resources
The official Mach II website
http://www.mach-ii.com/
The unofficial Mach II website
http://www.corfield.org/machii/
Mach II Development Guide
http://livedocs.macromedia.com/wtg/
public/machiidevguide/

no notes exist for this slide

Mach II at Macromedia


Mach II at Macromedia
Questions & Answers?
Sean A Corfield
scorfield@macromedia.com

no notes exist for this slide