![Page 1: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/1.jpg)
Mach II at MacromediaSean Corfield
Director, ArchitectureAn introduction to Mach II and its
use on macromedia.com
![Page 2: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/2.jpg)
2
Overview
• An introduction to Mach II
• What Macromedia is doing with Mach II
• Lessons Learned - Good & Bad
![Page 3: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/3.jpg)
3
Introduction
• What is Mach II?Definitions & BuzzwordsAn overview of how it works
• Why use Mach II?Pros & ConsAlternatives
![Page 4: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/4.jpg)
4
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
![Page 5: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/5.jpg)
5
What is Mach II? /ii
• Object-Oriented
• Strict Model View Controller structure
• Event-Based Implicit Invocation Architecture
![Page 6: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/6.jpg)
6
What is Mach II? /iii
![Page 7: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/7.jpg)
7
What is Mach II? /iv
• EventsGenerated by user (links, forms)Generated by application code
• ExampleUser tries to login (event=login)Login success (event=login_ok)Login failure (event=login_bad)
![Page 8: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/8.jpg)
8
What is Mach II? /v
• Event HandlersSpecified in XML (mach-ii.xml)Can notify "listener" CFCsCan render views (HTML)Can announce new eventsCan use filters to process data and affect
the flow of control
![Page 9: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/9.jpg)
9
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>
![Page 10: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/10.jpg)
10
What is Mach II? /vii
• Model - ColdFusion ComponentsBusiness Domain Objects"listeners" (for handling events)
• View - CFML pagesAlso layout templates, "pods" etc
• Controller - Mach IIXML configuration fileCore framework files
![Page 11: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/11.jpg)
11
What is Mach II? /viii
Mach II Application Structure
Application.cfm index.cfm
CFCs
/model
.cfm pages
/view
mach-ii.xml
/config
/appname
![Page 12: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/12.jpg)
12
What is Mach II? /ix
• ExtensibilityFilters
• CFCs that process data, announce events, change flow of control
• Invoked explicitly by event handlersPlugins
• CFCs that process data, announce events, change flow of control
• Invoked implicitly at key points in the event lifecycle
![Page 13: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/13.jpg)
13
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)
![Page 14: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/14.jpg)
14
Why use Mach II? /ii
• Good frameworks provide a "head start"• Based on sound engineering principles
MVC design patternImplicit Invocation Architecture
• StandardizationCommon structure for applications
• It supports "best practices"Good OO design / heavy use of CFCsLoose coupling / high cohesion
![Page 15: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/15.jpg)
15
Why use Mach II? /iii
• But . . .
• FrameworksRequire you use their style / idiomConstrain how you develop applications
• Mach II requires you use CFCs / OO / MVC / CFMX6.1
![Page 16: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/16.jpg)
16
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/
![Page 17: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/17.jpg)
17
Macromedia & Mach II
• Why did we choose Mach II?
• How are we contributing to Mach II?
• What applications use Mach II?
![Page 18: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/18.jpg)
18
Why we chose Mach II
• The macromedia.com team hadHeavy use of ColdFusion ComponentsInformal MVC approach in some apps
• But we wanted more standards and more structure in our applications
![Page 19: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/19.jpg)
19
Contributing to Mach II
• Macromedia was an early adopterDiscovered bugs (& provided fixes)Submitted enhancements (based on real-
world usage scenarios)Load testing & stability improvements
• Published Mach II Development Guide
![Page 20: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/20.jpg)
20
Applications using Mach II /i
• We started smallActive Content Resources administrator
• 6 filters, 14 event handlers, 2 listeners, 7 viewsBreeze Leads application
• 4 filters, 13 event handlers, 2 listeners, 6 viewsSome internal content management
applications• This proved the framework for us
without taking much of a risk
![Page 21: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/21.jpg)
21
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…
![Page 22: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/22.jpg)
22
Lessons Learned
• Benefits of using Mach II
• Downsides to using Mach II
• Freedom within the framework
• Load testing & thread safety
![Page 23: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/23.jpg)
23
Benefits of using Mach II /i
• Able to leverage existing CFCsBuilt an HTML version of Flash / CFC store in a
short space of time• Implicit Invocation
Reduced coupling & dependenciesEasier to change application flow
• Strict MVCSeparation of presentation and logicDeclarative controller (XML)
![Page 24: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/24.jpg)
24
Benefits of using Mach II /ii
• What our engineers sayMach II provides a head start on codingCommon 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
![Page 25: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/25.jpg)
25
Benefits of using Mach II /iii
• What our engineers sayGood 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!"
![Page 26: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/26.jpg)
26
Downsides to using Mach II
• What our engineers sayLack of documentationDebugging / Tool support
• Some community tools are now appearingPoor white space management
• Improved in 1.0.9Thread safety is big, big issue
![Page 27: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/27.jpg)
27
Freedom within the framework /i
• There's more than one way to do thingsFilters vs PluginsLayouts, PodsForm handlingRequest scope vs Event objectListener style
![Page 28: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/28.jpg)
28
Freedom within the framework /ii
• We used filters forSecurity / login authenticationPersistenceForm handlingLocalizationCachingOmniture click-stream tracking
![Page 29: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/29.jpg)
29
Freedom within the framework /iii
• We used plugins forApplication initialization / parametersLocalizationTracing / debugging / performance
analysis
• Note: two approaches to localization!
![Page 30: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/30.jpg)
30
Freedom within the framework /iv
• Layouts & PodsPortal / Grid LayoutsLots of small views, rendered to contentKey
variables (pods)Use layout template views to assemble pageUsually announce event to assemble pageCompositeView design pattern
![Page 31: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/31.jpg)
31
Freedom within the framework /v
• Form handlingBeaner filter
• Code was written before <event-bean> command was added!
Validation filter
• No custom form handling:All basic bean-based code
![Page 32: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/32.jpg)
32
Freedom within the framework /vi
• Request scope vs Event objectWe mostly follow the (original) Mach II
Development Guide recommendationsMostly use a few request scope variables
as the API to viewsUse a few event arguments where it is
clearer and more maintainable to do soThis is no longer considered best practice
for Mach II!
![Page 33: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/33.jpg)
33
Freedom within the framework /vii
• We have yet to choose one listener styleSome applications use a single listener as
a facade for the business modelSome applications use one or two simple
"manager" listenersSome applications use a lot of small,
single-function listeners
![Page 34: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/34.jpg)
34
Load testing & thread safety /i
• Mach II 1.0.9 is thread safeEarlier versions of the framework were not!Load testing highlighted random errors
• All CFCs are stored in application scopeNeed to use 'var' scope for all local
declarations in all functions!
![Page 35: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/35.jpg)
35
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" …>
![Page 36: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/36.jpg)
36
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
![Page 37: Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com](https://reader035.vdocuments.us/reader035/viewer/2022062905/5a4d1ad07f8b9ab059971031/html5/thumbnails/37.jpg)
37
Resources
• The official Mach II websitehttp://www.mach-ii.com/
• The unofficial Mach II websitehttp://www.corfield.org/machii/
• Mach II Development Guidehttp://livedocs.macromedia.com/wtg/
public/machiidevguide/