mach ii at macromedia sean corfield director, architecture an introduction to mach ii and its use on...

Post on 06-Jan-2018

216 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

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

TRANSCRIPT

Mach II at MacromediaSean Corfield

Director, ArchitectureAn introduction to Mach II and its

use on macromedia.com

2

Overview

• An introduction to Mach II

• What Macromedia is doing with Mach II

• Lessons Learned - Good & Bad

3

Introduction

• What is Mach II?Definitions & BuzzwordsAn overview of how it works

• Why use Mach II?Pros & ConsAlternatives

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

5

What is Mach II? /ii

• Object-Oriented

• Strict Model View Controller structure

• Event-Based Implicit Invocation Architecture

6

What is Mach II? /iii

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)

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

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>

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

11

What is Mach II? /viii

Mach II Application Structure

Application.cfm index.cfm

CFCs

/model

.cfm pages

/view

mach-ii.xml

/config

/appname

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

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)

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

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

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/

17

Macromedia & Mach II

• Why did we choose Mach II?

• How are we contributing to Mach II?

• What applications use Mach II?

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

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

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

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…

22

Lessons Learned

• Benefits of using Mach II

• Downsides to using Mach II

• Freedom within the framework

• Load testing & thread safety

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)

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

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!"

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

27

Freedom within the framework /i

• There's more than one way to do thingsFilters vs PluginsLayouts, PodsForm handlingRequest scope vs Event objectListener style

28

Freedom within the framework /ii

• We used filters forSecurity / login authenticationPersistenceForm handlingLocalizationCachingOmniture click-stream tracking

29

Freedom within the framework /iii

• We used plugins forApplication initialization / parametersLocalizationTracing / debugging / performance

analysis

• Note: two approaches to localization!

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

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

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!

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

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!

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" …>

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

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/

38

Mach II at Macromedia

• Questions & Answers?

• Sean A Corfield• scorfield@macromedia.com

top related