230 likes | 555 Views
CF Development Frameworks. The Buzz, The Reality, The Differences (or… they have their place, for sure!). Jared Rypka-Hauer - Architect and Lead Developer Continuum Media Group, LLC http://www.web-relevant.com. What is a “framework?”. Patterns
E N D
CF Development Frameworks The Buzz, The Reality, The Differences (or… they have their place, for sure!) Jared Rypka-Hauer - Architect and Lead Developer Continuum Media Group, LLC http://www.web-relevant.com
What is a “framework?” • Patterns • Think of building a house… where are the patterns in architecture and construction? • Rules • Do’s, Dont’s, and Best Practices… have you ever seen a roof on upside down? • Structure • Defined formats for walls, doors, windows, and roof. • Industry-wide Patterns and Rules provide standard doors, with potential for custom-fit options.
So a Framework Is… • Patterns • Lather, Rinse Repeat… or… • Do once, learn it, do it again… • Reuseable • Core Files – Walls, Floors, and Roof • Application Skeleton – Interior Decoration • Modules – Prefabricated or Prepackaged • Standardized • All instances of the framework have commonality • Facilitates communication, enables community support
What Does a Framework Do? Excerpts from http://www.javaworld.com/javaworld/jw-03-2004/jw-0329-keel.html
What the Java World Knows…Excerpts from the Keel intro Many challenges exist in software development: Projects must be developed quickly, yet be high-quality. For better code maintainability and application stability, they should utilize useful design patterns. Development projects must also integrate seamlessly with existing legacy systems while providing a path to more advanced technology, without the downtime or expense. And they must offer the freedom to choose how you implement and use new technology. In the face of these challenges, the software development community has turned to application frameworks to guide development. Application frameworks allow consistency in software design and provide low-level services that developers can use (and reuse) to speed development. The right application framework can dramatically reduce software development and maintenance costs. By using application frameworks, software developers can achieve the reusability and quality object-oriented programming promises but seldom delivers in the real world. -Daniel Silva in “Integrate software development frameworks” http://www.javaworld.com/javaworld/jw-03-2004/jw-0329-keel.html
Goals For Using Frameworks • Quality of End Product • Enhanced inclusion of new developers • Speed of Development Process • Reuse of Previous Work • Minimal Development for New Work • Maintainability • 70% - 80% of an application’s lifecycle is maintenance • Professional Quality and Reduced Costs
Common Components • Core Files – The Plans for a New House • Rambler? Tudor? Colonial? No, wait… • MVC, Procedural, OO, Services, and then some • Configuration – Where do I put the doors? • XML, often with a unique command-set • Skeleton Application • Model Home versus My Home • Common ColdFusion Frameworks • Mach II – OO gateway from Model to View • Fusebox – Flexible framework with it’s own vocabulary • Tartan – A new command-driven services framework
ColdFusion Frameworks Everything I know about MachII, Fusebox, and Tartan… (should take 10 minutes or less…)
(Just kidding… )MachII • Event-driven MVC framework for CF • MVC? Model, View, Controller… • NOT “Most Valuable Coder”… sorry. • XML configures events, listeners, application scope, and views • Data aggregation – more events, more views • Filters – altering behavior • Defined structure and Improved performance
<mach-ii version="1.0"> <!-- PROPERTIES --> <properties> <property name="applicationRoot" value="/atom2RSS" /> </properties> <!-- LISTENERS --> <listeners> <listener name="feedListener" type="atom2RSS.model.feedListener"> <invoker type="MachII.framework.invokers.CFCInvoker_Event" /> </listener> </listeners> <!-- EVENT-FILTERS --> <event-filters> <event-filter name="yourEventFilterName" type="fullyQualifiedDotDelimitedPathToCFC"> <parameters> <parameter name="yourParameterName" value="yourParameterValue" /> </parameters> </event-filter> </event-filters> <!-- EVENT-HANDLERS --> <event-handlers> <event-handler event="feedRSS" access="public"> <notify listener="feedListener" method="getRSS" resultKey="request.rssText" /> <view-page name="feed" /> </event-handler> </event-handlers> <!-- PAGE-VIEWS --> <page-views> <page-view name="feed" page="/views/feed.cfm" /> <page-view name="atomPrepare" page="/views/atomPrepare.cfm" /> <page-view name="exception" page="/views/exception.cfm" /> </page-views> <!-- PLUGINS --> <plugins> <!-- <plugin name="yourPluginName" type="fullyQualifiedDotDelimitedPathToCFC"> <parameters> <parameter name="yourParameterName" value="yourParameterValue" /> </parameters> </plugin> --> </plugins> </mach-ii>
Mach II –Properties and Listeners <!-- PROPERTIES --> <properties> <property name="applicationRoot" value="/atom2RSS" /> </properties> <!-- LISTENERS --> <listeners> <listener name="feedListener" type="atom2RSS.model.feedListener"> <invoker type="MachII.framework.invokers.CFCInvoker_Event" /> </listener> </listeners>
MachII –Events, Filters, and Plugins <!-- EVENT-FILTERS --> <event-filters> <event-filter name="yourEventFilterName" type="fullyQualifiedDotDelimitedPathToCFC"> <parameters> <parameter name="yourParameterName" value="yourParameterValue" /> </parameters> </event-filter> </event-filters> <!-- EVENT-HANDLERS --> <event-handlers> <event-handler event="feedRSS" access="public"> <notify listener="feedListener" method="getRSS" resultKey="request.rssText" /> <view-page name="feed" /> </event-handler> </event-handlers> <!-- PLUGINS --> <plugins> <plugin name="yourPluginName" type="fullyQualifiedDotDelimitedPathToCFC"> <parameters> <parameter name="yourParameterName" value="yourParameterValue" /> </parameters> </plugin> </plugins>
Mach II Request Cycle • Request is made of {url}/index.cfm • Passed to Mach-ii.cfm via cfinclude • Default or “event=“ in form or URL scope • Executes Event based on XML • The Gateway to your Business Objects • Automatically transfers URL and Form data into the Event object, available via arguments.event.getArg(argName) • Returns results via Event object parameter • resultKey aggregates views, Event aggregates data • HTTP response is sent to the client
Fusebox 4.1 – Easy, Standard, Flexible • Currently in use by at least 26,700 developers worldwide • Mature – in its fourth full upgrade • Personal Opinion: the most natural • Available documentation • www.Fusebox.org – docs and links • Widely commented on, lots of how-tos
Functional Fusebox 4.1 • Condenses functionality into Circuits • Main = controller • M = Model • V = View • Circuits are configured with Fuseactions • URL variable ?fuseaction=main.doSomething • XML-based “vocabulary” intelligent configuration • Do, Include, If, Instantiate, Loop, Invoke, etc. • Main.showDetail triggers m.getDetail and v.detailView
FB4 – XML Vocabulary From Circuit.xml in /controller <fuseaction name="benefits"> <do action="m.getAge"/> <assert expression="age GTE 65" message="age was #age#"/> <do action="m.getBenefits"/> <do action="v.showBenefits"/> </fuseaction> From Circuit.xml in /model <fuseaction name="getAge"> <include template="actGetAge"/> </fuseaction> From Circuit.xml in /view <fuseaction name="showBenefits"> <include template="dspBenefits"/> </fuseaction>
FB4 – A Simple Demonstration • Non-Fusebox • http://www.web-relevant.com • Fusebox • http://web-relevant.preview.digitalnorth.net • (DigitalNorth rocks, btw… ) • Time taken to convert simple views: • Any guesses?
TartanAn Object-oriented command-driven service framework for ColdFusion • What are Services? • Collections of Objects with commonality • Examples • Television Service – so many channels • Mobile phone service – can you hear me now? • Insurance services – 700 ways to profit (at your expense) • Services in Tartan • LocalService executes custom Command classes • Commands execute instructions in sequence • The Framework returns your results • <cfset myValue = localService.getMyValue(“me”) /> • May access many data sources, make transformations or conversions • Incorporates Service, Command(s), DAO(s), and ValueObject (bean) • Nice balance between OO structure and procedural thinking
Command Execution Cycle Issues Command Receives True Executes Command entirely within Tartan
Tartan Demo • http://webrelevant.preview.digitalnorth.net/tartanSamples/helloWorld • Calls localService.getGreeting(lang) • Executes framework code • Accesses datasource via DAO • Returns data via bean or value • DAO knows enough to say “no value available”
Personal Philosophy • This is MY personal feeling, nothing more • Websites are one thing… • …Enterprise class web-delivered applications are an entirely different beast. • Enterprise demands • standards, forms, patterns • Enterprise mandates • Cost control, quality, maintainability • Extensible and scaleable • Frameworks provide the “framework” to meet these needs, in OO, Procedural, or otherwise.
Professional Notes • Product coming out in Feb • http://w2ksrv1.neo.servequake.com/dbanalyzer • $25 development widget built for my own use • Quick Demo • cf.Objective(Minneapolis, 2006) • Geared toward OO/CF in the Enterprise • Currently have four nationally recognizable speakers • Local speakers: Kurt! • Seeking: • Hosting (web and venue) • Attendees • Input on date and content • Papers for seminars and presentations • Jared@web-relevant.com or cf.objective@gmail.com
Resources • Sean Corfield’s blog • http://www.corfield.org • Joe Rinehart’s blog • http://www.clearsoftware.com • Jared Rypka-Hauer’s blog • http://cfobjective.neo.servequake.com • Fusebox.org • http://www.fusebox.org • Mach-II.com • http://www.mach-ii.com • OpenXCF project on sourceforge.org • http://sourceforge.net/projects/openxcf • Other resources • Macromedia LiveDocs on Mach-II with lots of OO principles • http://livedocs.macromedia.com/wtg/public/machiidevguide/ • Trond Ulseth – MachII Tutorial • http://tutorial345.easycfm.com/