Slides and Code from My Code Generation Presentation

As promised, here are the slides and code from my cf.Objective() 2008 presentation, "Leveraging Code Generation to Jumpstart Your Development". Check the bottom of this entry for the enclosure.

So far the conference has been great. I've learned a lot at several sessions, including Andrew Powell's integration presentation on using Spring and Hibernate as the Java model for an app using CF for Controller and View. Chris Scott's ColdSpring presentation got my wheels turning with regard to custom Proxy Factories. And the announcement of the ColdFusion Open Initiative was most welcome, with a public bug base and more organized enhancement request system.

I'll post more after the conference is over, but so far it's been as good as I expected it to be!

Comments Comments (1) | Download Download | | Digg It! Digg It! | Linking Blogs Linking Blogs | 7973 Views

cf.Objective() 2008 Presenation on Code Generation

I've also been tapped to present at the 2008 cf.Objective() conference. My session is called "Leveraging Code Generation to Jumpstart Your Development".

There are two kinds of coding: fun and boring. We all want to focus on the fun kind, but unfortunately the boring, repetitive kind also has to get done. Luckily, a lot of the boring coding can be generated for us!

The underlying concepts of code generation will be discussed. This will include active and passive generation, along with the benefits and drawbacks of each approach.

I'll also look at using code generation to help you get to the fun stuff more quickly. Topics will touch on the full range of available code generation techniques, including CFEclipse Snippets, ANT build files, scaffolding, ORM frameworks, the Illudium PU-36 generator from Brian Rinaldi, and my UML to CFC Stub Generator. I hope to see you there! | Digg It! Digg It! | Linking Blogs Linking Blogs | 5434 Views

ColdMock and CFC Stub Generator Updates

Just a quick note about some updates to the RIAForge projects for ColdMock and the CFC Stub Generator.

ColdMock had an issue when trying to mock a method that was defined in a superclass of the target object. This has been corrected. It will also validate arrays of components as return types (i.e. User[]) (thanks to João Fernandes for contributing this fix).

The CFC Stub Generator has some significant additions as well. The tool now supports generating private and public properties if you define these in the UML. Public properties are set in the THIS scope, and associated cfproperty tags are created.

The tool also supports existing CFCs now. It will not overwrite existing components, but will still generate the other files (unit tests, ColdSpring, etc.). This will allow you to quickly generate unit tests for an existing set of components by spec'ing them out in UML.

You can also set up alternate package hierarchies in the tool to define paths to CFCs that are outside of your project (for example, Transfer), and mark a CFC as "active" in the UML tool to instruct the generator to use this path as opposed to the root path you defined for your main project. You must set up the alternate package path and set the base package for the alternate packages as "root" in the UML tool. In this way, the generator will know the proper paths to the external components for typing and ColdSpring path creation. Examples of this setup are included in the bookstore2.zuml/bookstore2.xmi files.

Finally, the tool now has an option to use ColdMock instead of generating staic mock CFC files, and configure the unit tests and the generated ColdSpring file to use the MockFactory to use in the unit tests (requires ColdMock and CF8).

Comments Comments (4) | | Digg It! Digg It! | Linking Blogs Linking Blogs | 6063 Views

CFC Stub Generator Now Defines ColdSpring Bean Dependencies

I made a quick update to the CFC Stub Generator to support creating the proper dependencies in the ColdSpring XML file that it generates. This will only work when using a UML XMI file as the generation source. When you define an aggregation or composition relationship in the UML, the generator knows about these relationships and creates the ColdSpring XML accordingly. So, if you have a UML diagram like this:

The ColdSpring XML that gets generated would look like this:


	<bean id="Config" class="bookstore.components.beans.Config" />		
	<bean id="MockConfig" class="bookstore.components.beans.mock.MockConfig" />
	<bean id="AbstractService" class="">
		<property name="Config">	
			<ref bean="Config" />
		<property name="SessionFacade">	
			<ref bean="SessionFacade" />
	<bean id="MockAbstractService" class="" />
	<bean id="StoreService" class="">
		<property name="StoreFactory">	
			<ref bean="StoreFactory" />
	<bean id="MockStoreService" class="" />
	<bean id="StoreFactory" class="bookstore.components.factories.StoreFactory" />		
	<bean id="MockStoreFactory" class="bookstore.components.factories.mock.MockStoreFactory" />
	<bean id="Membership" class="bookstore.components.businessobjects.Membership" />		
	<bean id="MockMembership" class="bookstore.components.businessobjects.mock.MockMembership" />
	<bean id="Product" class="bookstore.components.businessobjects.Product" />		
	<bean id="MockProduct" class="bookstore.components.businessobjects.mock.MockProduct" />
	<bean id="SessionFacade" class="bookstore.components.facades.SessionFacade" />		
	<bean id="MockSessionFacade" class="bookstore.components.facades.mock.MockSessionFacade" />

As you can see, the bean dependencies that are created in the ColdSpring XML match the aggregation relationships defined in the UML. This is pretty handy if you plan to copy the ColdSpring XML that is used by the generated test suite in your real application. It also makes it easy to modify this XML to pass Mock objects into your components when creating your tests. | Digg It! Digg It! | Linking Blogs Linking Blogs | 9561 Views

CFC Generator 1.6 With A Few UML Generation Enhancements

I've updated the CFC Stub Generator RIAForge Project with a few new items:

  • A few bugs and typos were fixed.
  • Added an option from Nat Papovich regarding the documentation tab from Poseidon. Any text included in the Poseidon 'documentation' tab for that method will either be inserted into the 'hint' attribute of the CFFUNCTION tag, OR be placed into the body of the CFFUNCTION tag set as a CFML comment. This option is set on the Stub Generator configuration screen.
  • Strip HTML from Documenation: This option can be turned off or on in the Configuration Options screen. Since the Poseidon documentation tab is a rich text editor, HTML markup can end up in your generated hints or CFML comments. Some people like to have HTML in their hints to make viewing it in the Component Browsers more readable so I left this in as an option.
  • Getter and Setter Generation: This option can be turned off or on in the Configuration Options screen. If a method starts with "get", the generator will add in code to return an instance variable with the name of the method. i.e., if you have a UML method called "getName", the generator will add the code

    <cfreturn />

    Along the same line, if a method starts with "set" and has one argument, the generator will add in code to set the variable. i.e., if you have a UML method called "setName" with a single argument called "name", the generator will add the code

    <cfset = />

    I realize this won't always be correct, but I figured it wouldn't hurt much since it does eliminate a lot of mundane typing and if it incorrectly adds code for a method that you didn't really mean to be a getter or setter, it's very easy to delete that code. This option can be turned off or on in the Configuration Options screen.

  • Composition and Aggregation: The tool does detect aggregation or composition between components and inserts a custom attribute to the CFCOMPONENT tag called "aggregates" and lists aggregated components in a comma-delimited list. This isn't used by ColdFusion, but in the event that I create a tool that can read CFCs and generate the UML diagram, this attribute would allow the UML to be aware of composition and aggregation in your CFCs. This option can be turned off or on in the Configuration Options screen.
  • Readme updated

Comments Comments (3) | | Digg It! Digg It! | Linking Blogs Linking Blogs | 6976 Views

More Entries