| By Tom Schreck | Article Rating: |
|
| October 13, 2006 12:00 PM EDT | Reads: |
11,601 |
Managed Code and Round Trip Editing
So, what are
managed code blocks? Managed code blocks are "tags" that are placed
inside your CFC that wrap a block of code. I use the term "tags"
loosely. It's really special comments that cfcPowerTools searches for
when regenerating a CFC. If the code is outside a managed code block,
then it's ignored. The special comments say where to get the content
that goes between the managed code comments. A pretty simple concept,
but very powerful.
Managed code blocks support round-trip editing. Round-trip editing means you can interact with your CFC manually or via a tool and not lose code. The only time you lose code is when you add code within a managed code block section because everything between the tags gets regenerated. Managed code is the process of designating "sections" of your code that cfcPowerTools will reproduce. Managed code blocks can be put in a <cfscript> block or anywhere else throughout your CFC.
So what happens if something goes wrong? Auto-backups of CFCs are generated prior to applying any changes during regeneration. A history is generated of the modifications made to your CFC files.
This is a managed code pattern:
<!--- START MANAGEDCODE BLOCK: [CFC PACKAGE].[CFCNAME]:[METHOD] --->
... GENERATED CODE GOES HERE...
<!--- END MANAGEDCODE BLOCK --->
cfcPowerTools searches your CFC code for "START MANAGEDCODE BLOCK:" then instantiates the CFC (using the package and cfc name) listed in the pattern and calls the method that will regenerate the block of code.
Below is an example of a managed code block:
<!--- START MANAGEDCODE BLOCK: cfcPowerTools.library.codeSource:getManagedCodeProperties --->
... GENERATED CODE GOES HERE...
<!--- END MANAGEDCODE BLOCK --->
cfcPowerTools.library.codeSource CFC is instantiated and the getManagedCodeProperties method is consumed. This method regenerates the code and returns it to be included in the CFC when it gets rewritten. This method is responsible for regenerating everything inside the managed code block.
Here's an example of using managed code inside <cfscript>:
<cfscript>
...
//START MANAGEDCODE BLOCK: cfcPowerTools.library.codeSource:getManagedCodeInstanceData
... GENERATED CODE GOES HERE...
//END MANAGEDCODE BLOCK
...
</cfscript>
Sections of your code that deal with properties, <cfproperty> tags, and SQL statements are ideal candidates for managed code blocks. If a CFC doesn't have any managed code blocks then cfcPowerTools will only create the CFC the very first time. CFCs without managed code blocks can't be modified.
So as you can see managed code plays an important role for solving the synchronization challenge when change happens.
The Guts of cfcPowerTools
cfcPowerTools approaches
CFCs and database tables by focusing on the property. Typically,
properties have been used for documentation purposes. cfcPowerTools
uses them as a direct correlation to fields in a database table.
Properties are generated for each field in a table. In doing so,
cfcPowerTools gathers a bunch of data that describes the property in
terms of how the property is used in the CFC, database, and data entry
form. All of this data is stored in a generated XML metadata file. The
XML File is governed by a XML schema.
Data Entry Forms
Another productivity feature is
form generation. cfcPowerTools use the metadata XML document that
describes how properties are "seen" in a data entry form to generate
the form. Raw data entry forms are generated. Remember, the purpose is
to get the grunt work out of the way, not to produce production-ready
code. You're still the developer. HTML, XML, and FLASH forms are
supported. Typically, you take the generated form and modify it to your
needs.
Example Code
The links below are examples of code
generated by cfcPowerTools. Each zip file contains CFCs and data entry
forms for several tables in the Northwind database. These examples
demonstrate the code generated for the Model Controller and Mach II CFC
Types.
www.cfcpowertools.com/downloads/ModelController.zip
www.cfcpowertools.com/downloads/MachII.zip
Pseudo-Code
The improved Component Doc view lets
you interact with your CFC in ways you couldn't before. You can create
and append CFC functions to your CFC via the new Component Doc view.
Powering your productivity goes a step further by letting you enter
pseudo-code when creating new functions. You use pseudo-code as a
reminder of what the function is supposed to do. Pseudo-code increases
your productivity by describing the function so you can fill in the
actual code at a later date.
Figure 5 provides an example of a <cffunction> generated from a UI with pseudo-code notes.
Wrapping Up
cfcPowerTools is not an end-all be-all
and it's not trying to be all things to everyone. It won't do your
dishes or tie your shoes. It doesn't produce your final code base. You
still have to use your skills as a developer. It doesn't and won't
replace your skills. It's simply a tool that will make you more
productive, generate a consistent base code, and let you focus on the
work of engineering the business rules, behaviors, and presentation and
not the plumbing of the application.
For more information, please visit www.cfcpowertools.com.
Published October 13, 2006 Reads 11,601
Copyright © 2006 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Tom Schreck
Tom Schreck is a Macromedia certified ColdFusion MX 6.1 developer. He has been working with ColdFusion since 1997. Check out www.cfcPowerTools.com for more information on cfcPowerTools.
![]() |
Edgar 10/04/07 11:55:55 PM EDT | |||
the URL to www.cfcpowertools.com does not work. |
||||
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Adobe May Cooperate with Apple to Transplant Flash Player to iPhone
- Adobe Flex Developer Earns $100K in New York City
- Adobe LiveCycle Enterprise Suite 2 for Cloud Computing
- Adobe Betas Target RIAs and Cloud Computing
- Adobe Cans Another 9% of its Workforce
- Moyea DVD4Web Converter V2.0 Converts DVD to FLV Fast and Synchronously with Watermarks
- Adobe Fiddles with its Web Apps
- Adobe & Salesforce Cut Cloud Deal
- Hosting.com Launches ColdFusion 9 in the Cloud
- The Real Time Infrastructure Ultimatum
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Eval JavaScript in a Global Context
- Fig Leaf Software to Exhibit at Government IT Conference & Expo
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Is Microsoft as Free as Open Source?
- Adobe Reader Sued
- The Planet Named “Bronze Sponsor” of Cloud Computing Expo
- Microsoft Expression Web Has Got Game
- Adobe May Cooperate with Apple to Transplant Flash Player to iPhone
- Adobe Flex Developer Earns $100K in New York City
- Bruce Chizen Joins Voyager Capital as Venture Partner
- My Top Seven Wishes From Adobe MAX 2009
- The Next Programming Models, RIAs and Composite Applications
- Where Are RIA Technologies Headed in 2008?
- Constructing an Application with Flash Forms from the Ground Up
- AJAX World RIA Conference & Expo Kicks Off in New York City
- CFEclipse: The Developer's IDE, Eclipse For ColdFusion
- Personal Branding Checklist
- Adobe Flex 2: Advanced DataGrid
- Has the Technology Bounceback Begun?
- Building a Zip Code Proximity Search with ColdFusion
- i-Technology Viewpoint: We Need Not More Frameworks, But Better Programmers
- The Asynchronous CFML Gateway
- Web Services Using ColdFusion and Apache CXF





























