The amazing adventures of Doug Hughes

I make no secret that I like love Model-Glue. I will admit, if you do not have a decent grasp on Object-Oriented processes, Model-Glue might seem a bit over complicated, but sometimes it just saves so much time and effort.

One example of this happened yesterday. I am working on a project that uses Model-Glue. There was a requirements change for one part of the application. It wasn’t anything major. I needed to remove something that was appearing on one particular page, and move it to a different page. Now, if your application is well-architected, this will be an easy process, however, in this instance, I did not even need to move any ColdFusion code. All I had to do was move some XML blocks from one <event-handler> to another and re-initialize the application.

Here is what the original <event-handler> looked like, the snippets we are concerned about are in bold.

<event-handler name="DisplayEnd">
    <broadcasts>
        <message name="CheckIfLoggedIn">
            <argument name="redirectToEvent" value="LoginForm"/>
        </message>
        <message name="NeedToGetPageManager"/>
        <message name="NeedMessage">
            <argument name="message" value="End"/>
        </message>
        <message name="NeedGraphicId">
            <argument name="grahicId" value="End"/>
        </message>
	   <message name="NeedAudioMessage">
            <argument name="audioMessageType" value="ending"/>
		</message>
    </broadcasts>
    <views>
        <include name="topContent" template="display/dspMessageText.cfm"/>
        <include name="bottomContent" template="display/dspMessageGraphic.cfm"/>
        <span style="font-weight: bold;"><include name="audioMessage" template="display/dspAudioMsg.cfm"/>
        </span>
    </views>
    <results>
        <result do="DisplayLayout"/>
    </results>
</event-handler>

What the highlighted bits of XML tell us is that when an event named ‘DisplayEnd’ is called, such as http://www.mysite.com?event=displayEnd, certain messages get broadcast, including ‘NeedAudioMessage’. When that message is broadcast, we are also passing along an argument with the name of ‘audioMessageType’ and a value of ‘ending’. (This is available inside of any Model-Glue controller by using arguments.event.getArgument(‘audioMessageType’). Lastly, it tells us that, among others, we are including a ColdFusion page named dspAudioMsg.cfm.

I will not get into the particulars of the code that exists inside of the controller, it merely checks certain conditions and then simply adds a value to the event if an audio message should be displayed.

The change was that instead of displaying this audio message on the DisplayEnd page, the client wanted it to be displayed on the GoalMet page. All I needed to do was remove the 2 highlighted XML blocks from the original <event-handler>, and move them into the new one. Since the logic that determined whether or not we needed an audio message had not changed, there was no need to change any of the ColdFusion code. The XML looked like this:

<event-handler name="GoalMet">
    <broadcasts>
        <message name="CheckIfLoggedIn">
            <argument name="redirectToEvent" value="LoginForm"/>
        </message>
        <message name="NeedToGetPageManager"/>
        <message name="NeedMessage">
            <argument name="message" value="Congratulatory"/>
        </message>
        <message name="NeedGraphicId">
            <argument name="grahicId" value="Congratulatory"/>
        </message>
        <message name="NeedAudioMessage">
            <argument name="audioMessageType" value="ending"/>
        </message>
    </broadcasts>
    <views>
        <include name="topContent" template="display/dspMessageText.cfm"/>
        <include name="bottomContent" template="display/dspMessageGraphic.cfm">
            <value name="xeNext" value="index.cfm?event=DaisyEnd"/>
        </include>
        <span style="font-weight: bold;"><include name="audioMessage" template="display/dspAudioMsg.cfm"/></span>
    </views>
    <results>
        <result do="DisplayLayout"/>
    </results>
</event-handler>
<event-handler name="DisplayEnd">
    <broadcasts>
        <message name="CheckIfLoggedIn">
            <argument name="redirectToEvent" value="LoginForm"/>
        </message>
        <message name="NeedToGetPageManager"/>
        <message name="NeedMessage">
            <argument name="message" value="End"/>
        </message>
        <message name="NeedGraphicId">
            <argument name="grahicId" value="End"/>
        </message>
    </broadcasts>
    <views>
        <include name="topContent" template="display/dspMessageText.cfm"/>
        <include name="bottomContent" template="display/dspMessageGraphic.cfm"/>
    </views>
    <results>
        <result do="DisplayLayout"/>
    </results>
</event-handler>

Now, as long as the same conditions are met, we will get an audio message in the GoalMet event rather than the DisplayEnd event, all without writing or changing one line of CF code.

Comments on: "Reason #526 Why I Like Model-Glue" (51)

  1. Brian Kotek said:

    Loose coupling rules. It RULES! 😉

    Like

  2. Michael Long said:

    Okay… but if you’d used a different architecture, say a component-based non-XML MVC system, wouldn’t you still have just moved the method call from controller A to controller B?

    Heck, even in a well-designed old-school CF application, wouldn’t you have just included or called a cfmodule from B instead of A? Again just moving a few lines of code/text?

    Sorry, but given the result it still seems a bit over-complicated.

    Like

  3. Karl Snyder said:

    We just recently had code built on top of the Model-Glue and ColdSpring frameworks. I’d have to admit that Model-Glue is complicated and was intimidating (it sometimes still is).

    Scott has an excellent point that really exposes the usefullness of Model-Glue. The keywords are “there was no need to change any of the ColdFusion code”. Yeah, so mostly any change can expose your system to bugs if the change isn’t handled correctly but when merely configuration is changed it’s magic. Code changes are usually always a more dangerous change for us.

    We outsource most of our development to India, if it was up to me we wouldn’t but that’s besides the point. Everytime our India team fixes something there’s a 50% chance they will break something. Seriously, “the fix one bug open two is a process we’ve had to live with”. Model-Glue has already made our lives easier when dealing with our outsourced teams. One fresh developer was able to successfully make two pages with little code and instead Model-Glue configuration and both pages were bug free. Now, that’s just amazing!

    Like

  4. Sony DCR-TRV320 Battery Charger said:
  5. Sony MVC-FD5 Battery Charger said:

    [url=http://www.chargers-battery.net/chargers.php/7,62086,sony,mvc-fd5,charger.htm]Sony MVC-FD5 Battery Charger[/url]

    Like

  6. Sony CCD-TRV408 Battery Charger said:

    Sony CCD-TRV408 Battery Chargerhttp://www.chargers-battery.net/chargers.php/7,62118,sony,ccd-trv408,charger.htm

    Like

  7. Sony DCR-PC105 Battery Charger said:

    Sony DCR-PC105 Battery Chargerhttp://www.chargers-battery.net/chargers.php/7,62150,sony,dcr-pc105,charger.htm

    Like

  8. Sony DCR-TRV460E Battery Charger said:

    Sony DCR-TRV460E Battery Chargerhttp://www.chargers-battery.net/chargers.php/7,62197,sony,dcr-trv460e,charger.htm

    Like

  9. Sony DCR-TRV460E Battery Charger said:
  10. Bsi NB8600 Battery, NB8600 Battery Pack said:

    Bsi NB8600 Battery, NB8600 Battery Pack
    http://www.chargers-battery.net/laptop-battery/bsi-battery-146.htm

    Like

  11. Sony DCR-TRV360 Battery Charger said:
  12. luxuning said:

    I believe that XML provide a good way to promote the ueser experience when people browsing the website based on HTML language. since the Web 2.0 is coming, what can remain the most customers? the answer is a delightful
    Website, remember, no matter what the customer wants to buy, first feeling, second purchasing. and the key point is ueser experience.

    ———————————————–
    http://www.toshiba-laptop-battery.com/toshiba-satellite-a70-seires.htm

    Like

  13. Sony DCR-TRV360 Battery Charger said:
  14. Sony DCR-DVD201 Battery Charger said:

    Sony DCR-DVD201 Battery Chargerhttp://www.chargers-battery.net/chargers.php/7,62131,sony,dcr-dvd201,charger.htm

    Like

  15. luxuning said:

    If you’re using Eclipse, you probably have an XML file editor like XMLBuddy, Aptana or the Web Standards Tools installed. It can be frustrating to debug a non-working app for hours only to realize that you made a mistake in your modelglue.xml!

    By incorporating a DOCTYPE statement at the top of any model-glue XML configuration file, you can develop faster knowing that Eclipse will alert you to any problems in your file.

    http://www.toshiba-laptop-battery.com/toshiba-satellite-m30-series.htm

    Like

  16. Since most manufacturers focus their support on Windows and Mac users, users of other operating systems often are unable to receive support for these devices. However, open source products such as Cinelerra and Kino (written for the Linux operating system) do allow full editing of some digital formats on alternative operating systems, and software to edit DV streams in particular is available on most platforms.

    Many low-end tapeless camcorders, however, do not support any operating system but Windows, requiring either third-party software or a switch to a more standardized format such as DV.
    http://super-camcorder-battery.com/

    Like

  17. espowbattery said:

    New Original hp laptop battery — PB994A
    save 40% off
    http://www.hp-laptop-batteries.net/pb994a.htm

    Like

  18. Discount battery shop supply laptop battery and camcorder battery.
    http://www.discount-battery.org

    Like

  19. http://www.power-batteries.net
    http://www.laptop-battery-inc.co.uk
    http://www.buy-batteries.net

    Great laptop battery,camcorder battery,digital camera battery on US market & UK market.

    Like

  20. http://www.power-batteries.ne: A leading supplier of rechargeable battery on US market.Specializes in laptop battery, camcorder battery, digital camera battery, external laptop battery, laptop battery charger, power supply adapter and camcorder battery charger.Offers camera/camcorder battery charger for sales. PDA Battery & Digital Photo Frame at low price. Power-batteries.net sells a wide range of batteries for Two Way Radio and MP3 player(includes IPOD).

    http://www.laptop-battery-inc.co.uk

    UK market battery seller, provides high quality & cheap laptop batteries for major notebook computer brands,such as ACER, COMPAQ,DELL, FUJITSU,HP,IBM,LENOVO,SONY,TOSHIBA; digital camera battery for CANON,FUJIFILM,KODAK,MINOLTA ,NIKON,OLYMPUS and SONY; Camcorder battery for CANON,HITACHI,JVC,PANASONIC,SAMSUNG,SHARP,SONY; Digital Photo Frame at great price; USB Bluetooth Adapter and laptop AC adapter.

    Like

  21. http://www.buy-batteries.net

    Specializes in rechargeable laptop batteries for ACER, COMPAQ,DELL, FUJITSU,HP,IBM,LENOVO,SONY,TOSHIBA;Offers discount camcorder battery for CANON,HITACHI,JVC,PANASONIC,SAMSUNG,SHARP,SONY; Brand new digital camera battery,provides best replacement for OEM camera battery, featured brands:CANON,FUJIFILM,KODAK,MINOLTA ,NIKON,OLYMPUS and SONY; AC adapter,laptop battery charger,camera battery charger are available from our online store.

    Like

  22. i am tina from New Jersey,i work as a internet seller,my website http://www.cheap-digital-camera-batteries.co.uk , http://www.batteriescenter.co.uk , http://www.ibm-laptop-batteries.net http://www.usa-batteries.com are great online store where you can shop any kind of replacement battery at the lowest prices.Anyone who uses batteries of any sort, for any purpose may take advantage of my web page,good luck!

    Like

  23. batteries and chargers said:

    Battery -chargers.org supply many camcorder batteries,digital camera batteries and chargers with factory price,high quality,1 year warranty and 30 days money back!
    http://www.battery-chargers.org/

    Like

  24. Hi all,
    I found an excellent SHARP vl-e720 battery at http://www.laptop-battery-inc.co.uk/camcorder-batteries/sharp-vl-e720.htm.

    Like

  25. laptopbattery said:

    Welcome to online laptop battery store, we offer high quality laptop batteries: Sony laptop battery, TOSHIBA laptop battery, Dell laptop battery, Acer laptop battery, Compaq laptop battery, HP laptop battery … … http://www.laptop-battery.org.uk/ Your need,is our eternal pursuit; Your satisfaction,is our high honour; Thank you for your support . http://www.battery-store.eu/

    Like

  26. At espow.org we offer the widest selections of third party replacement batteries with the lowest prices, good battery life performance. Best laptop batteries – hp laptop batteries, ibm laptop battery, sony computer battery, dell laptop batteries, compaq laptop batteries, notebook desktop computer batteries…
    http://www.espow.org
    http://www.hp-laptop-batteries.com
    http://www.battery-store.ca

    Like

  27. Li-ion Dell inspiron 6400 laptop battery – 7200mAh 11.1V, spare or replacement for laptop power need, compatible many parts, It’s also an universal smart battery for Dell inspiron 6400, Dell GD761,Dell KD476 .Dell inspiron 6400 battery for most existing laptop parts, longer Dell INSPIRON 6400 battery life performance.no memory, don’t worry about the rechargeable frequently.

    http://www.espow.org/laptop-batteries/dell-inspiron-6400.htm

    Like

  28. Li-ion Sony np-bk1 digital camera battery – 550mAh 3.7V DC, spare or replacement for digital camera power need, compatible many parts DSC-S750, DSC-S780,no memory, don’t worry about the rechargeable frequently. Having good battery life performance. Increase the shooting time on your DSC-S750 and S780 Cyber-shot digital camera with this slim yet powerful Lithium-ion battery pack.

    http://www.espow.org/digital-camera-batteries/sony-np-bk1.htm

    Like

  29. Li-ion HP PAVILION DV9000 laptop battery – 7200mAh 14.40V, spare or replacement for laptop power need, compatible many parts, no memory, don’t worry about the rechargeable frequently. Having good battery life performance. It’s also an universal smart battery for HP PAVILION DV9000, PAVILION ZE5490US …

    http://www.espow.org/laptop-batteries/hp-pavilion-dv9000-battery.htm

    Like

  30. batterystore said:

    DELL TT485 computer batteries,Laptop Battery
    Buy DELL TT485 Laptop Battery from battery-store.eu, brand new, one year warranty, full compatible with: DELL TT485
    http://www.battery-store.eu/laptopcomputer/dell-tt485-1001566.htm

    Like

  31. Li-ion Dell INSPIRON 8600 laptop battery – 6600mAh 11.1V (Compatible with 10.8V), spare or replacement for laptop power need, compatible many parts, no memory, don’t worry about the rechargeable frequently. Having good battery life performance. It’s also an universal smart battery for Dell INSPIRON 8600, INSPIRON 8600M SERIES, LATITUDE D800 SERIES, PRCISION M60 MOBILE WORKSTATION

    http://www.espow.org/laptop-batteries/dell-inspiron-8600.htm

    Like

  32. Laptop batteries,camcorder batteries,digital camera batteries …

    http://www.espow.org
    http://www.hp-laptop-batteries.com
    http://www.battery-store.ca

    Like

  33. laptop battery said:

    I got the right info about toshiba portege 4000 battery on http://www.adapterlist.com/toshiba/portege-4000.htm toshiba portege 4000 battery ,i sure it will fit my notebook .

    Like

  34. laptop bettery said:

    If you want to buy some idear laptop betteries,you can see it from hp pb994a battery,It’s very cool.

    Like

  35. used computer said:

    it doesn’t not get into the particulars of the code that exists inside of the controller, it merely checks certain conditions and then simply adds a value to the event if an audio message should be displayed.

    Like

Comments are closed.

Tag Cloud