<?xml version="1.0" encoding="utf-8"?>
			
			<rss version="2.0">
			<channel>
			<title>Objective Action - CodeGeneration</title>
			<link>http://www.objectiveaction.com/Kevin/index.cfm</link>
			<description>An Objective Look at Adobe and the Internet</description>
			<language>en-us</language>
			<pubDate>Wed, 08 Sep 2010 13:31:25+0100</pubDate>
			<lastBuildDate>Mon, 26 Jan 2009 20:48:00+0100</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>kevin@objectiveinternet.com</managingEditor>
			<webMaster>kevin@objectiveinternet.com</webMaster>
			
			
			
			
			
			<item>
				<title>onMissingMethod and Abstract Objects</title>
				<link>http://www.objectiveaction.com/Kevin/index.cfm/2009/1/26/onMissingMethod-and-Abstract-Objects</link>
				<description>
				
				I have finally got around to working a bit more on the fusebox scaffolder project. One of the things I have meaning to do was improve the generated code by using an abstract bean and letting generated beans inherit some base methods. I intend to do this for most of the generated cfcs, but just started with the bean as a first step.

I have not in the past used onMissingMethod but now enough of what I am doing is on CF8 that I decided it was worth incorporating in the generated code. I began by reading up about it to see 
&lt;a href=&quot;http://code.google.com/p/org-corfield-cfmx/source/browse/trunk/wwwroot/org/corfield/component.cfc?r=71&quot; target=&quot;_blank&quot;&gt;what&lt;/a&gt;
&lt;a href=&quot;http://www.pbell.com/index.cfm/2008/4/14/Rebuilding-my-Base-Object&quot; target=&quot;_blank&quot;&gt;others&lt;/a&gt; 
&lt;a href=&quot;http://www.aliaspooryorik.com/blog/index.cfm/e/posts.details/post/140&quot; target=&quot;_blank&quot;&gt;had&lt;/a&gt;
&lt;a href=&quot;http://www.bennadel.com/blog/868-Learning-ColdFusion-8-OnMissingMethod-Event-Handler.htm&quot; target=&quot;_blank&quot;&gt;done&lt;/a&gt;.

There was certainly lots of ideas out there and I decided to take John Whish&apos;s &lt;a href=&quot;http://www.aliaspooryorik.com/blog/index.cfm/e/posts.details/post/140&quot;&gt;dynamicAccessors.cfc&lt;/a&gt; and take it a bit further.

John&apos;s idea was to make use of the &amp;lt;cfproperty&amp;gt; tag to set up the properties in a cfc and then to make use of the onMissingMethod in a base cfc to create dynamic accessors. I really like this idea but I also like Peter Bell&apos;s idea for controlling the access to the getters and setters through a list of property names. 

I was wondering about combining the two ideas and remembered somthing I discovered in the early days of CFCs. You can actaully create your own attributes on many of the CF tags just by adding them to the tag.

So I can write:
&lt;code&gt;
&lt;cfproperty name=&quot;title&quot; type=&quot;string&quot; settable=&quot;true&quot; gettable=&quot;true&quot;/&gt;
&lt;/code&gt;
and ColdFusion will ignore my two new attributes in most respects. What it will do is add them to the metadata so I can read them. This allows me to extend John&apos;s getAccessors() method to update two new structures one for the setters and one for the getters.

&lt;code&gt;
&lt;cffunction name=&quot;getAccessors&quot;
			hint=&quot;I build a structure of public properties and data types.&quot; 
			access=&quot;public&quot;&gt;
		&lt;cfset var metadata = &quot;&quot; /&gt;
		&lt;cfset var properties = arrayNew(1) /&gt;
		&lt;cfset var index = &quot;&quot; /&gt;
			
		&lt;cfif StructKeyExists( variables.instance, &quot;_properties&quot; ) 
			AND StructKeyExists( variables.instance, &quot;_getable&quot; )
			AND StructKeyExists( variables.instance, &quot;_setable&quot; )
			AND IsStruct( variables.instance._properties )
			AND IsStruct( variables.instance._gettable )
			AND IsStruct( variables.instance._settable )&gt;
			
			&lt;cfdump var=&quot;#variables.instance._properties#&quot;/&gt;
			&lt;cfdump var=&quot;#variables.instance._gettable#&quot;/&gt;
			&lt;cfdump var=&quot;#variables.instance._settable#&quot;/&gt;
			&lt;cfabort/&gt;
			
			&lt;cfreturn variables.instance._properties /&gt;
		&lt;cfelse&gt;
			&lt;!--- The first time we get or set a property we need to build a structure of properties and types ---&gt;
			&lt;cfset variables.instance._properties = {} /&gt;
			&lt;cfset variables.instance._gettable = {} /&gt;
			&lt;cfset variables.instance._settable = {} /&gt;
			
			&lt;cfset metadata = getMetaData(this)&gt;
			
			&lt;cfloop condition=&quot;structKeyExists(metadata,&apos;properties&apos;) OR structKeyExists(metadata,&apos;extends&apos;)&quot;&gt;
				&lt;cfif structKeyExists(metadata,&quot;properties&quot;)&gt;
					&lt;cfset properties = metadata.properties /&gt;
					&lt;cfloop array=&quot;#properties#&quot; index=&quot;index&quot;&gt;
						&lt;cfif IsDefined(&quot;index.type&quot;)&gt;
							&lt;cfset StructInsert( variables.instance._properties, index.name, index.type ) /&gt;
						&lt;cfelse&gt;
							&lt;cfset StructInsert( variables.instance._properties, index.name, &quot;any&quot; ) /&gt;
						&lt;/cfif&gt;
						&lt;cfif IsDefined(&quot;index.getable&quot;)&gt;
							&lt;cfset StructInsert( variables.instance._gettable, index.name, index.getable ) /&gt;
						&lt;cfelse&gt;
							&lt;cfset StructInsert( variables.instance._gettable, index.name, &quot;false&quot; ) /&gt;
						&lt;/cfif&gt;
						&lt;cfif IsDefined(&quot;index.setable&quot;)&gt;
							&lt;cfset StructInsert( variables.instance._settable, index.name, index.setable ) /&gt;
						&lt;cfelse&gt;
							&lt;cfset StructInsert( variables.instance._settable, index.name, &quot;false&quot; ) /&gt;
						&lt;/cfif&gt;
					&lt;/cfloop&gt;
				&lt;/cfif&gt;
				&lt;cfif structKeyExists(metadata,&quot;extends&quot;)&gt;
					&lt;cfset metadata = metadata.extends&gt;
				&lt;cfelse&gt;
					&lt;cfset metadata = &quot;&quot;&gt;
				&lt;/cfif&gt;
			&lt;/cfloop&gt;
			
			&lt;cfreturn variables.instance._properties /&gt;	  
		&lt;/cfif&gt;
			
	&lt;/cffunction&gt;
&lt;/code&gt;
I now have two new structures in my object which I can use to test if the generated code should allow you to set or get each property.

A small change to the onMissingMethod() function and I can now control who has access quite easily.

What I really want to know is: Am I mad to do this? After all I am arbitarily extending the language and I didn&apos;t ask anyones permission.

27Jan 16:25 GMT  - Modified to fix a couple of typos.
				
				</description>
						
				
				<category>ColdFusion</category>				
				
				<category>Scaffolding</category>				
				
				<category>CodeGeneration</category>				
				
				<pubDate>Mon, 26 Jan 2009 20:48:00+0100</pubDate>
				<guid>http://www.objectiveaction.com/Kevin/index.cfm/2009/1/26/onMissingMethod-and-Abstract-Objects</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Fusebox Beta and Alpha releases</title>
				<link>http://www.objectiveaction.com/Kevin/index.cfm/2007/10/2/Fusebox-Beta-and-Alpha-releases</link>
				<description>
				
				Yesterday at MAX Sean Corfield announced the release of &lt;a href=&quot;http://corfield.org/blog/index.cfm/do/blog.entry/entry/Fusebox_55_Public_Beta&quot; target=&quot;_blank&quot;&gt;Fusebox 5.5 Public Beta&lt;/a&gt;.

There is a &lt;a href=&quot;http://fusebox.org/go/fusebox-downloads/beta-program&quot; target=&quot;_blank&quot;&gt;new page&lt;/a&gt; on the Fusebox web site with links to all the modules.

One of the modules vailable on the beta page is my &lt;a href=&quot;http://fusebox.org/download.cfm?downloadfile=5B5D6872-9F2F-7E0A-22CAA43D1C530259&amp;typename=dmFile&amp;fieldname=filename&quot; target=&quot;_blank&quot;&gt;scaffolding code&lt;/a&gt; which is not strictly a Beta as its currently in Alpha. If you would like to take part in Alpha testing please let me know. I am keen to see people using the tool to generate applications and to get as many of the bugs as possible in the current code tracked down before we start adding the features for the next Alpha 2 version which should include some other databases.

Sean has also put the Fusebox 5.5 release notes on Share so demostrating the usefulness of the new service.
				
				</description>
						
				
				<category>Scaffolding</category>				
				
				<category>Fusebox</category>				
				
				<category>CodeGeneration</category>				
				
				<pubDate>Tue, 02 Oct 2007 09:06:00+0100</pubDate>
				<guid>http://www.objectiveaction.com/Kevin/index.cfm/2007/10/2/Fusebox-Beta-and-Alpha-releases</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Tutorial on Code Generators</title>
				<link>http://www.objectiveaction.com/Kevin/index.cfm/2007/2/12/Tutorial-on-Code-Generators</link>
				<description>
				
				Todd Sharp has posted the &lt;a href=&quot;http://cfsilence.com/blog/client/index.cfm/2007/2/12/Getting-Started-With-Code-Generators--Part-1&quot; target=&quot;_blank&quot;&gt;first of a series of blogs on Code Generators&lt;/a&gt;. The first article features the &lt;a href=&quot;http://code.google.com/p/cfcgenerator/&quot; target=&quot;_blank&quot;&gt;Illudium PU-36 Code Generator&lt;/a&gt; by Brian Rinaldi.
				
				</description>
						
				
				<category>CodeGeneration</category>				
				
				<pubDate>Mon, 12 Feb 2007 18:06:00+0100</pubDate>
				<guid>http://www.objectiveaction.com/Kevin/index.cfm/2007/2/12/Tutorial-on-Code-Generators</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Domain-Specific Modeling</title>
				<link>http://www.objectiveaction.com/Kevin/index.cfm/2007/2/10/DomainSpecific-Modeling</link>
				<description>
				
				There is a good article on Domain-Specific Modeling in the &lt;a href=&quot;http://www.architecturejournal.net/2006/issue9/F2_Domain/&quot; target=&quot;_blank&quot;&gt;Microsoft Architecture Journal&lt;/a&gt;. I am interested to know if anyone is using this kind of technology with ColdFusion.

Is there a similar open source tool available for drawing Domain-Specific Models?
				
				</description>
						
				
				<category>DSL</category>				
				
				<category>Scaffolding</category>				
				
				<category>CodeGeneration</category>				
				
				<pubDate>Sat, 10 Feb 2007 10:41:00+0100</pubDate>
				<guid>http://www.objectiveaction.com/Kevin/index.cfm/2007/2/10/DomainSpecific-Modeling</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>1:45 pm Peter Bell - Application Generation - Beyond Scaffolding</title>
				<link>http://www.objectiveaction.com/Kevin/index.cfm/2007/2/1/145-pm-Peter-Bell--Application-Generation--Beyond-Scaffolding</link>
				<description>
				
				Peter spoke about: Language Oriented Programming which can allow you to create more reusable code. What is required to build a code generator. Software product lines can be used to deliver projects in certain cases. Look at way to generate a web application.

Scaffolding will automatically generate code to create forms, lists and view pages for an object. It is typically done by using the database to provide the metadata. Eg Reactor.

There are limits to what can be done that way. User has to add extra code later to make up for the limitation of the database metadata. 

Language Oriented Programming is a new approach to programming which improves the metadata. Everyone is doing it:

OMG: Model Drive Architecture.

Microsoft: Sofware Factories.

JetBrains IntelliJ Meta Programming system.

CF Custom Tags or UDFs are ways to do some similar things. Modify the language to create a domain specific language. CFCs do this too....  The reason is to encapsulate complexity.

Layered software allows you to create a domain specific language to solve the problems. Good programmers often begin with a pseudo-code to describe the problem then replace the code with real calls to real routines.

Horizontal DSLs:

SQL,&lt;br /&gt;
Reg_Ex,&lt;br /&gt;
Objects,&lt;br /&gt;
Notifications,&lt;br /&gt;
ColdSpring XML,&lt;br /&gt;
Reactor XML.

Vertical DSLs:&lt;br /&gt;
Newetter,&lt;br /&gt;
Insurance Quotes&lt;br /&gt;

Three types of DSL:&lt;br /&gt;
Declarative,&lt;br /&gt;
Templating,&lt;br /&gt;
Scripting.


Declarative languages are ideal for reuse. Templating languages simplify for designers. Scripting languages are used to implement the solution.

What vs How

It really does not matter which language gets used.

ColdFusion, XML, Special, Diagrams.

There are three types of code generator:

Passive (not much use),&lt;br /&gt;
Active (easier),&lt;br /&gt;
Roundtrip (difficult).&lt;br /&gt;

Metadata can be stored in text files, XML or a database.

The code can be generated using a templating language. Eg XSLT or ColdFusion.

CFTemplate can be used.

Iterator is required: One DAO per object, one template per screen etc.

Orchestrator is required: described by Metadata.

You will never generate everything because it is quicker to handle separately, eg Safe code snippets or Inheritance.

Anatomy of a generator:
Metadata, Templates, Iterator, Orchestrator, Extensions.

Need to be able to generate the code in minutes. Use a feature model and allow wizards to select features. 

There is an object model and an interface model.

Content&lt;br /&gt;
@LiveDate: Optional: Datetime: 1/1/2000&lt;br /&gt;
@Status: Required: Status: approved&lt;br /&gt;

Use custom data types to describe the interface model. 

Screens can be defined by:&lt;br /&gt;
@Type=List,&lt;br /&gt;
@Paging=Yes,&lt;br /&gt;
@RecordsPerPage=50.

Layer software product lines for higher levels of reuse.

CFGen and CFTemplate will be available at &lt;a href=&quot;http://www.pbell.com&quot;&gt;http://www.pbell.com&lt;/a&gt; in the next few weeks.
				
				</description>
						
				
				<category>Conferences</category>				
				
				<category>Frameworks</category>				
				
				<category>Scaffolding</category>				
				
				<category>CodeGeneration</category>				
				
				<pubDate>Thu, 01 Feb 2007 19:40:00+0100</pubDate>
				<guid>http://www.objectiveaction.com/Kevin/index.cfm/2007/2/1/145-pm-Peter-Bell--Application-Generation--Beyond-Scaffolding</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>10:15 am Chip Temm - Model driven development and code generation</title>
				<link>http://www.objectiveaction.com/Kevin/index.cfm/2007/2/1/1015-am-Chip-Temm--Model-driven-development-and-code-generation</link>
				<description>
				
				Tooling required for model driven development to create code and database from the model.

The presentation was forward looking, presenting ideas where not much code exists yet to do this kind of thing in CF.

Quality is important and the goal is repeatable success. Process is important and should be about developing software rather than to fulfil a management objective.

Documentation is used to pull together the Design, Development and Maintenance process. The code documentation is a big challenge, which developers don&apos;t like to do. Using the model to generate the code allows the model to be seen as a key step in the process.

Multiple projects and moving from project to project means the developers will need to move to new projects and the knowledge evaporates.

Is the code clear? Do we need to design documents? Modelling the metadata will communicate the design. You can use reflection to extract the component metadata. 

The designs can be copied into other projects and improve the productivity of programmers.

Generating code framework will allow the work to be distributed to multiple developers.

Forward generating code is easier when you have the whole model available.

Refactoring can be made easier. ColdFusion is a difficult language to parse.

The generator can also generate unit test tools.

Tools Overview:
Most UML modelling tools now support code generation, Java is the target and CF is not supported out of the box. Adalon has support for Fusebox 4.

Most tools export to XMI and some have extended XMI.

Tigris.org  Argo UML  Free; has a facility to create templates.
Sparx Systems  Enterprise Architect - $200 : Goodvalue
Gentlesoft  Poseidon - $900 (based on Argo UML)

Choices: Use the XMI and create your own generator. 

As an example 2MB file for two classes with a few methods. Most is related to the diagram. So it pays to focus on the model.

Use the tool to define the metadata and generate XMI, which can be used to create the code. The tool will not contain the CF datatypes. You may have to create a package and create CF datatypes in that first.

You can use XSL templates to convert the XMI or use ColdFusion to create the generator.

www.cfopen.org has an experiment called open model to try and do this. The code there is not production quality.

There is also a cfcXMI plugin for Poseidon which create class files for the app using the model.

Sparx has better templating but nothing for CF yet. 

Converting code to models (round tripping):

Code needs to have reliable metadata. (Not type = &quot;any&quot;)
Define properties with &lt;cfproperty&gt; to allow it to know about the properties.

Challenges: Some tools have support for PHP. We need to show support for CF in these tools. Round tripping CF is hard because it is not XML compliant. Flex should be easier because it is XML and Poseidon already supports Actionscript. 
Fear of wizards.

Persistence methods are easy to generate but custom methods are difficult or impossible to generate.

Investment cost issues.

How many people I there to change? What will the tools cost?

What is the risk of change?

&lt;a href=&quot;http://anthrologik.net/presentations/dc_frameworks_2007_02_01.ppt&quot;&gt;Presentation&lt;/a&gt;
&lt;a href=&quot;http://del.icio.us/chiptemm/&quot;&gt;Links&lt;/a&gt;
				
				</description>
						
				
				<category>Conferences</category>				
				
				<category>CodeGeneration</category>				
				
				<pubDate>Thu, 01 Feb 2007 16:13:00+0100</pubDate>
				<guid>http://www.objectiveaction.com/Kevin/index.cfm/2007/2/1/1015-am-Chip-Temm--Model-driven-development-and-code-generation</guid>
				
			</item>
			
		 	
			</channel></rss>