<?xml version="1.0" encoding="utf-8"?>
			
			<rss version="2.0" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cc="http://web.resource.org/cc/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">

			<channel>
			<title>ArgumentCollection - Broadchoice Engineering - Model-Glue</title>
			<link>http://blog.broadchoice.com/index.cfm</link>
			<description>The Broadchoice engineering team blog.</description>
			<language>en-us</language>
			<pubDate>Mon, 06 Sep 2010 13:39:36 -0400</pubDate>
			<lastBuildDate>Mon, 03 Nov 2008 17:52:00 -0400</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>ac@broadchoice.com</managingEditor>
			<webMaster>ac@broadchoice.com</webMaster>
			<itunes:subtitle></itunes:subtitle>
			<itunes:summary></itunes:summary>
			<itunes:category text="Technology" />
			<itunes:category text="Technology">
				<itunes:category text="Podcasting" />
			</itunes:category>
			<itunes:category text="Technology">
				<itunes:category text="Tech News" />
			</itunes:category>
			<itunes:keywords></itunes:keywords>
			<itunes:author></itunes:author>
			<itunes:owner>
				<itunes:email>ac@broadchoice.com</itunes:email>
				<itunes:name></itunes:name>
			</itunes:owner>
			<itunes:image href="" />
			<image>
				<url></url>
				<title>ArgumentCollection - Broadchoice Engineering</title>
				<link>http://blog.broadchoice.com/index.cfm</link>
			</image>
			<itunes:explicit>no</itunes:explicit>
			
			
			
			
			
			<item>
				<title>Is it ColdFusion or Groovy?</title>
				<link>http://blog.broadchoice.com/index.cfm/2008/11/3/Is-it-ColdFusion-or-Groovy</link>
				<description>
				
				Here at &lt;a href=&quot;http://www.broadchoice.com&quot;&gt;Broadchoice&lt;/a&gt; we&apos;ve been working on our &lt;a href=&quot;http://blog.broadchoice.com/index.cfm/2008/9/7/Behind-The-Curtain&quot;&gt;new product&lt;/a&gt; for close to three months now. I&apos;ve gotten a crash course in Groovy, Spring, and Hibernate, all of which are slightly familiar to me from my time with ColdSpring, Transfer, and Java. I&apos;m really digging these new technologies, but of course, I&apos;m a die hard ColdFusion user at heart. A few weeks backs I needed to work on a quick iPhone web application prototype. Joe set up the connection and all I had to do was write CFML (lucky me). Little did I know that along with setting up basic CFML compatibility on the server, Joe also added one of the slickest things I&apos;ve seen ever in my life as a developer.

The application I&apos;m working on is pretty simple, but I wanted to use Model-Glue 3 for it since - well - you never know when a simple prototype will turn into a large, complex application. The following code snippet comes from a controller used to load bookmarks:

&lt;code&gt;
    &lt;cffunction name=&quot;getBookmarks&quot; output=&quot;false&quot;&gt;
        &lt;cfargument name=&quot;event&quot; /&gt;
        &lt;cfset var u = arguments.event.getValue(&quot;currentuser&quot;)&gt;
       
        &lt;!--- In theory currentuser should always exist, but... ---&gt;
        &lt;cfif not isSimpleValue(u)&gt;
            &lt;!--- space only? ---&gt;
            &lt;cfif arguments.event.valueExists(&quot;space&quot;)&gt;
                &lt;cfset arguments.event.setValue(&quot;bookmarks&quot;, beans.contentService.findContentBySpace(arguments.event.getValue(&quot;space&quot;),[&quot;Bookmark&quot;]))&gt;
            &lt;cfelse&gt;
                &lt;cfset arguments.event.setValue(&quot;bookmarks&quot;, beans.contentService.findUsersContent(u,[&quot;Bookmark&quot;]))&gt;
            &lt;/cfif&gt;
        &lt;/cfif&gt;
           
    &lt;/cffunction&gt;
&lt;/code&gt;
      
Nothing in the above code should be too odd or even that exciting really. I&apos;m using a service (injected via the beans scope in Model-Glue 3) to retrieve my content. My controller begins with...

&lt;code&gt;
&lt;cfcomponent output=&quot;false&quot; hint=&quot;I am a Model-Glue controller.&quot; extends=&quot;ModelGlue.gesture.controller.Controller&quot;
    beans=&quot;contentService,config&quot;
&gt;
&lt;/code&gt;

Note the beans value specifies which beans configured in ColdSpring should be passed to my controller. I love this new automation in Model-Glue 3. If you open up my ColdSpring.xml file, you will see my beans configured:

&lt;code&gt;
&lt;bean id=&quot;config&quot; class=&quot;ModelGlue.Bean.CommonBeans.SimpleConfig&quot;&gt;
    &lt;property name=&quot;config&quot;&gt;
        &lt;map&gt;
            &lt;entry key=&quot;profileimageroot&quot;&gt;&lt;value&gt;/some url you dont need to know&lt;/value&gt;&lt;/entry&gt;
            &lt;entry key=&quot;filesroot&quot;&gt;&lt;value&gt;/something else you dont need to worry about&lt;/value&gt;&lt;/entry&gt;
            &lt;entry key=&quot;perpage&quot;&gt;&lt;value&gt;10&lt;/value&gt;&lt;/entry&gt;           
        &lt;/map&gt;
    &lt;/property&gt;
&lt;/bean&gt;   
&lt;/code&gt;

Hmmm. Ok, there&apos;s my config bean, wheres my contentService bean? Oh yeah - here it is:

&lt;code&gt;
    &lt;bean id=&quot;contentService&quot; class=&quot;com.broadchoice.bcp.services.ContentService&quot;&gt;
        &lt;property name=&quot;dao&quot; ref=&quot;contentDAO&quot;/&gt;
        &lt;property name=&quot;sessionFacade&quot; ref=&quot;sessionFacade&quot; /&gt;
        &lt;property name=&quot;sharedFileGateway&quot; ref=&quot;sharedFileGateway&quot; /&gt;
        &lt;property name=&quot;eventMessageDispatcher&quot; ref=&quot;eventMessageDispatcherService&quot; /&gt;
    &lt;/bean&gt;
&lt;/code&gt;

You can find the above in our Spring file. Just in case the above didn&apos;t quite make get through, let me make it real nice and obvious:

&lt;code&gt;
&lt;cfset arguments.event.setValue(&quot;bookmarks&quot;, beans.contentService.findContentBySpace(arguments.event.getValue(&quot;space&quot;),[&quot;Bookmark&quot;]))&gt;
&lt;/code&gt;

The above line of CFML is using a bean injected from Spring, not ColdSpring, and points to a Groovy file. This is the same Groovy code used to drive the AIR application. No createObject(&quot;java&quot;) here baby. I&apos;m using the Groovy code just like it had come from a CFC. This is done using a ColdSpring/Spring adapter that Joe wrote. It lets ModelGlue get Java-based beans from Spring. (I&apos;m simplifying it here a bit, but hopefully you get the significance of that!) Once that connection is done, you can easily get beans from the Spring file and inject them into your controller. So for example, when my UserController wanted do handle login, I added: beans=&quot;userService,config&quot; and then simply ran a userService.validateAndLoad on the authentication information.

It&apos;s always been easy to use Java from CFML, but never has been so sexy! Now to be fair, I did have to use a JavaCast once or twice, but not nearly as much as I would have thought.
				
				</description>
						
				
				<category>Groovy</category>				
				
				<category>Broadchoice Shares Knowledge</category>				
				
				<category>ColdSpring</category>				
				
				<category>Spring</category>				
				
				<category>Model-Glue</category>				
				
				<category>Tools and Technology</category>				
				
				<pubDate>Mon, 03 Nov 2008 17:52:00 -0400</pubDate>
				<guid>http://blog.broadchoice.com/index.cfm/2008/11/3/Is-it-ColdFusion-or-Groovy</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Writing your Second Model-Glue Application</title>
				<link>http://blog.broadchoice.com/index.cfm/2008/8/14/Writing-your-Second-ModelGlue-Application</link>
				<description>
				
				So the title is a bit of a trick. This really isn&apos;t about writing your second Model-Glue application, but more about the kinds of things you see when comparing earlier Model-Glue applications to those you write after having a few under your belt. Most likely a lot of what I&apos;m going to talk about applies to other frameworks as well, so this isn&apos;t just a Model-Glue concern. When I arrived at &lt;a href=&quot;http://www.broadchoice.com&quot;&gt;Broadchoice&lt;/a&gt;, the older version of our product had already been updated to use the Model-Glue framework. The primary developer team behind this update had just learned Model-Glue. A lot of what I saw looked very similar to how I had built Model-Glue sites when I began. Here are a few items to consider when building your next Model-Glue application. 

&lt;b&gt;Model-View-Controller need not be singular...&lt;/b&gt;&lt;br /&gt;
For those of us who were new to MVC, the idea of nicely separating back end logic from front end views was a godsend. Sure it meant a bit more work up front, but the benefits later on were more than worth the effort. I think this is the thing I appreciated the most about MVC. So, like most people, I began to work with a controller, a ModelGlue.xml file, and maybe a few model files and my directory of views. This worked fine for a smaller site, but as the site began to grow, my XML configuration and controller file began to explode. When I needed to find an event, I was scrolling through 1000 lines of XML. Even if I used a nice naming scheme (more on that below), it was a chore to work with. When I began using Model-Glue, there wasn&apos;t a simple solution for this. Luckily the framework added support for XML includes. 

I ran into the same issue with my controller as well. The file had become too large to manage. It didn&apos;t even occur to me to use multiple controllers until I had done a few Model-Glue sites, but now that I have I wouldn&apos;t do it any other way. My typical approach is to break up the controllers by &quot;areas of concern&quot; - which is my way of referring to the major parts of the application. So for example, a typical site may have a User, Product, and News controller. Each would be responsible for handling events related to their areas. So the User controller would handle listening to getUser. Product would listen to getProduct. Etc. 

I still keep a controller named, well, Controller, because I find that there are typically events that don&apos;t fall into any one particular category. I also still put a few events in the main ModelGlue.xml file. 

What&apos;s nice about MVC, and where I think it really &quot;sinks in&quot; for developers new to the concept, is that you can update a Model-Glue site to fix this problem and not lose a drop of functionality. So at Broadchoice, I&apos;ve been slowing breaking things up a bit when there are available cycles. This has zero impact on the product for the end user but has the side effect of making it easier to update the application.

I also recommend breaking up the views folder. It may start small, but before you know it any semi-complex site can grow quite complex. The main idea here is to make it as simple as possible for someone to find the right code when performing updates.

&lt;b&gt;Inconsistent Naming&lt;/b&gt;&lt;br /&gt;
Ok, so this may be more of an issue for those of us who are anal retentive about naming, but I really get bothered when my event names don&apos;t follow a standard naming pattern. Inconsistent naming is an even bigger problem if the files aren&apos;t properly broken up (see above). There are no hard and fast rules for what makes a good event name. My typical rule is &quot;area of concern&quot;.&quot;action&quot;, so I will typically have events like:

&lt;ul&gt;
&lt;li&gt;product.edit
&lt;li&gt;user.authenticate
&lt;li&gt;planet.destroy
&lt;/ul&gt;

This way it&apos;s always clear what type of data (or area of the application) is being worked with, and what type of action is being performed. Once again, the beauty of MVC is that you can make these types of corrections when you have time for it. There are two potential problems with this.

First - you may have existing URLs that rely on certain event names. In the past I&apos;ve handled this by either using a URL rewrite or by catching the &quot;missing event&quot; error in Model-Glue. Model-Glue 3 adds support for handling missing events directly so this will get even cleaner. While you should put some thought into how you name your events, it may make sense to pay extra attention to those events the users will actually see (and possibly bookmark). 

The second problem is a bit harder to fix. If you change the event that is run when a user logs in, it isn&apos;t just enough to update the XML. You also have to remember to update the view layer as well. I was never really a big fan of the XFA technique. This is a Fusebox concept whereby you tell the view what to use for particular events. (I believe this originated with Fusebox - if anyone knows better, speak up!) So instead of me hard coding action=&quot;index.cfm?event=user.authenticate&quot; in the form tag, I&apos;d pass it to the view layer and make the action dynamic. After doing some refactoring on our product, which made heavy use of XFAs in Model-Glue, I&apos;m really happy they were used. Here is a simple example from one of our views:

&lt;code&gt;
&lt;views&gt;
	&lt;view name=&quot;body&quot; template=&quot;documents/documents.cfm&quot; append=&quot;true&quot;&gt;
		&lt;value name=&quot;xe.view&quot; value=&quot;document.document.view&quot; /&gt;
		&lt;value name=&quot;xe.list&quot; value=&quot;Documents&quot; /&gt;
		&lt;value name=&quot;xe.edit&quot; value=&quot;document.document.edit&quot; /&gt;
	&lt;/view&gt;
&lt;/views&gt;
&lt;/code&gt;

Note the use of the value subkey inside the view node. This will add the values to the viewState. You would then use these when creating any links within the view.

&lt;b&gt;Anything else?&lt;/b&gt;&lt;br /&gt;
This is - in general - the big things I&apos;ve noticed when looking at first generation Model-Glue sites. I&apos;m curious to see what others have discovered as well, so please chime in with your comments. 

I&apos;ll add one more thing to the list - I wish like heck I had made more use of auto-wiring and ColdSpring in general. Until you see a good example of an application that uses this you don&apos;t truly get how much work it can save you.
				
				</description>
						
				
				<category>Model-Glue</category>				
				
				<category>Broadchoice Shares Knowledge</category>				
				
				<pubDate>Thu, 14 Aug 2008 18:45:00 -0400</pubDate>
				<guid>http://blog.broadchoice.com/index.cfm/2008/8/14/Writing-your-Second-ModelGlue-Application</guid>
				
			</item>
			
		 	
			</channel></rss>