May 16, 2008

Pages


Search Site


Topics


Useful Links

Blogs I Read


Archives

Entries Tagged as 'ColdSpring'

Belated cf.Objective() 2008 Thoughts

May 07 2008 by Andrew Powell

I've been a bit busy since leaving St. Paul, so I've not had the time to collect my thoughts on cf.Objective() until today.  

My initial thoughts are that it was a better show than last year. The content was, again, top notch.  The food and hotel were great, and the people were, as always, the best part.  It was good to meet new faces and reconnect with old friends & people I only know via blog comment conversations.

There were very few sessions that I went to that disappointed me and didn't meet my expectations.  The first highlight, for me, was the coming out party for Mate (http://mate.asfusion.com) & Swiz (http://code.google.com/p/swizframework/).  I think that by this time next year, they will have matured into full fledged alternatives to Cairngorm.  They're both well on their way now.  

The second highlight was the ColdFusion 9 BOF.  It was, without a doubt, the single most rowdy session I've ever attended at a conference (my & Brian's contributions not withstanding).  As much as there were a lot of truer OO functionality pieces asked for, I couldn't help but think:  "Why not learn Java?", but that's another blog post.  The knowledge gap in the room was almost palpable, but I think the "thought leaders" of the CF Community (as someone so eloquently put it in another review) should accept the challenge and step up and help close the gap for those that want to get into hardcore CF development.  How do we do that?  I don't have a damn clue right now, I'm just throwing ideas out.

I'm going to go on record as saying that for both price and quality of content, cf.Objective() is the single best conference for ColdFusion developers, hands down.  There is no competition.  And, yes, I was a shameless shill for my buddies at 360|Flex, the Flex world's equivalent.  

That being said, you sure better know what you're doing with ColdFusion when you walk in the door.  All content can be considered "200 level" and above.  If you're a cfNoob, you'll be way lost and over your head.  Plain and simple.

On to my session.... 

I had a LOT of blank stares in my session, but I kind expected that.  I know the stuff I was doing was going to be way over a lot of people's heads.  I will be posting a comprehensive HOWTO document on setting up Spring & Hibernate with ColdFusion in the next few days.  There are a few people who really got it and even extended it to work with ColdSpring (good job, Joe).   If I confused you, just try to remember to look at ColdFusion (the server) as just another J2EE app and it will be an easier task for you.

That's about all I've got.  Feel free to comment on my session or whatever you like. 

Posted in Cairngorm | Java | ColdFusion | Flex | General | Conferences | BlazeDS | ColdSpring | Spring | Adobe | Mach-II | Hibernate | XML | Speaking | 0 comments

My Google Code Site

March 12 2008 by Andrew Powell
After talking to Ben Stucki at 360|Flex, I decided that I should create a Google Code site for my code samples and preso posts. I am currently in the process of moving all my os code and preso samples into this repository for public consumption. Going forward, you will be able to find all my code samples there. It is released under the MIT License, which basically means, it's released "as is" and without warranty. Some things will be posted and never updated again. Other things will be updated and improved. There is no set schedule for projects to be updated, it's just a central point for you to find my code samples. My Google Code Site

Posted in Java | ColdFusion | Flex | Caching | General | Conferences | BlazeDS | Spry | JMS | ColdSpring | StockQuoter | Google | Spring | Adobe | Universal Mind | Hibernate | Air | Hessian | XML | Speaking | 0 comments

ColdSpring, Interfaces, & ColdFusion 8

December 12 2007 by Andrew Powell
With ColdFusion 8 came interfaces. Anyone who has developed in Java with Spring will tell you that the crux of the Spring framework and its IOC container is the ability to define your dependencies as interfaces. ColdFusion didn't have the ability to use interfaces until the latest release, CF8. Interfaces, mixed with ColdSpring, give us the ability to apply loose coupling between our services and their dependencies. Our service: <cfcomponent output="false">
   <cffunction name="init" access="public" returntype="net.infoaccelerator.stockWatcher.services.StockService">
      <cfset variables.TO = structNew()/>
      <cfreturn this/>
   </cffunction>
   
   <cffunction name="setStockDAO" access="public" returntype="void">
      <cfargument name="stockDAO" type="net.infoaccelerator.stockWatcher.business.dao.IStockDAO" required="true"/>
      
      <cfset variables.TO.stockDAO = arguments.stockDAO/>
   </cffunction>
.
.
.
</cfcomponent>
Notice that the service takes, as an argument to the setStockDAO method, the IStockDAO interface. This means that we can pass in any CFC that implements the IStockDAO interface. The Interface CFC: <cfinterface>
   
   
   <cffunction name="create" output="false" returntype="net.infoaccelerator.stockWatcher.vo.StockVO">
      <cfargument name="stockVO" type="net.infoaccelerator.stockWatcher.vo.StockVO" required="true"/>
   </cffunction>
   
   <cffunction name="read" output="false" returntype="net.infoaccelerator.stockWatcher.vo.StockVO">
      <cfargument name="symbolString" type="string" required="true"/>
   </cffunction>
   
   <cffunction name="update" output="false" returntype="Boolean">
      <cfargument name="stockVO" type="net.infoaccelerator.stockWatcher.vo.StockVO" required="true"/>
   </cffunction>
   
   <cffunction name="delete" output="false" returntype="Boolean">
      <cfargument name="stockVO" type="net.infoaccelerator.stockWatcher.vo.StockVO" required="true"/>
   </cffunction>
   
   
</cfinterface>
Now, let's look at the implementation: <cfcomponent output="false" implements="net.infoaccelerator.stockWatcher.business.dao.IStockDAO">
   <cffunction name="init" access="public" returntype="net.infoaccelerator.stockWatcher.business.dao.StockDAO">
      <cfreturn this/>
   </cffunction>
   
   <cffunction name="create" output="false" returntype="net.infoaccelerator.stockWatcher.vo.StockVO">
      <cfargument name="stockVO" type="net.infoaccelerator.stockWatcher.vo.StockVO" required="true"/>
      
      <cfset var serializedCFC = ""/>
      
      <cfset var fileOut = CreateObject("java", "java.io.FileOutputStream")>
      <cfset var objOut = CreateObject("java", "java.io.ObjectOutputStream")>
      
      <cfset fileOut.init(expandPath('/DATA_FILES/') & arguments.stockVO.getSymbol() & '.scfc')>
      <cfset objOut.init(fileOut)>
      <cfset objOut.writeObject(arguments.stockVO)/>
      <cfset objOut.close()>
      
      <cfreturn arguments.stockVO/>
      
   </cffunction>
   
   <cffunction name="read" output="false" returntype="net.infoaccelerator.stockWatcher.vo.StockVO">
      <cfargument name="symbolString" type="string" required="true"/>
      
      <cfset var stockVO = ""/>
      
      
      <cfset var fileIn = CreateObject("java", "java.io.FileInputStream")>
      <cfset var objIn = CreateObject("java", "java.io.ObjectInputStream")>
      
      <cfif fileExists(expandPath('/DATA_FILES/') & arguments.symbolString & '.scfc')>
         <cfset fileIn.init(expandPath('/DATA_FILES/') & arguments.symbolString & '.scfc')>
         <cfset objIn.init(fileIn)>
         <cfset stockVO = objIn.readObject()>
         <cfset objIn.close()>
         <cfelse>
            <cfset stockVO = createObject('component','net.infoaccelerator.stockWatcher.vo.StockVO').init()/>
      </cfif>
      <cfreturn stockVO/>
      
   </cffunction>
   
   <cffunction name="update" output="false" returntype="Boolean">
      <cfargument name="stockVO" type="net.infoaccelerator.stockWatcher.vo.StockVO" required="true"/>
      
      <cfset var serializedCFC = ""/>
      
      <cftry>         
         <cffile action="delete" file="#expandPath('/DATA_FILES/')##arguments.stockVO.getSymbol()#.scfc"/>
         
         <cfset create(arguments.stockVO)/>
         <cfreturn true/>
         <cfcatch type="any">
            <cflog file="StockWatcher" text="#cfcatch.message#"/>
            <cfreturn false/>
         </cfcatch>
      </cftry>
      
   </cffunction>
   
   <cffunction name="delete" output="false" returntype="Boolean">
      <cfargument name="stockVO" type="net.infoaccelerator.stockWatcher.vo.StockVO" required="true"/>
      
      <cftry>
         <cffile action="delete" file="#expandPath('/DATA_FILES/')##arguments.stockVO.getSymbol()#.scfc"/>
         <cfreturn true/>
         <cfcatch type="any">
            <cflog file="StockWatcher" text="#cfcatch.message#"/>
            <cfreturn false/>
         </cfcatch>
      </cftry>
   </cffunction>
   
</cfcomponent>
ColdSpring Config: <beans>

<bean id="stockService" lazy-init="true" class="net.infoaccelerator.stockWatcher.services.StockService">
<!-- these properties refer to other beans that are (or will be) defined -->
<property name="stockDAO">
<ref bean="stockDAO"/>
</property>
</bean>


<bean id="stockDAO" lazy-init="true" class="net.infoaccelerator.stockWatcher.business.dao.StockDAO"/>
<bean id="stockVO" lazy-init="true" singleton="false" class="net.infoaccelerator.stockWatcher.vo.StockVO"/>
<bean id="quoteVO" lazy-init="true" singleton="false" class="net.infoaccelerator.stockWatcher.vo.QuoteVO"/>
</beans>
What does this mean? As long as we wire in a DAO that implements the IStockDAO interface, we're good to go. We can create any type of DAO, but as long as it implements that IStockDAO interface, it doesn't matter. We can easily swap a file-based DAO for a database DAO, as long as the new DAO properly implements the interface. It's that simple. The full code is attached as a zipped CFEclipse project.

Posted in ColdFusion | General | ColdSpring | Universal Mind | Hibernate | 5 comments

"OO-like" != Object Oriented

October 16 2007 by Andrew Powell
"OO-like" is a phrase that is often overlooked when it comes to CFML and CFCs. A lot of developers like to glance over the "like" part of that expression and make the assertion that CFML, via CFCs, is an OO language. Well, it's not, but that is an easy leap to make. After all, there are a lot of OO-like patterns emerging for use in ColdFusion. When you try to do things with CFML like implementing complex data models with many circular references, ColdFusion, as an engine, has a hard time keeping up. This is no fault of ColdFusion's. It's just people are falling into the trap of expecting all OO practices and methodologies to work perfectly in a non-OO system. Before you get all bent out of shape, even Adobe has said that, "...CFML is not an object-oriented language, and CFCs don't provide all the features and functionality typically provided by OOP languages." This is not necessarily a bad thing. CFCs have accelerated the emergence of the MVC pattern in ColdFusion (Fusebox, Mach-II, ModelGlue, etc). Those MVC frameworks can still be leveraged to build powerful applications that are "OO-like" in their patterns, but at the end of the day, not truly OO applications. Sure, there are ORM and AOP/IOC frameworks available for ColdFusion that have their roots in an OO language. Aren't these really just a stepping stone on the way to learning Java though? If you are an advanced enough developer to understand how to properly use frameworks like Transfer, Reactor, ColdSpring, and other frameworks that, like these, have their roots in Java, shouldn't you be looking at developing parts (services, gateways, daos, vo's) of your application in Java anyway? Adobe has made great strides, though, in accomodating more OO features (interfaces, etc) with the latest release of ColdFusion 8. At the end of the day, in my mind, what holds CF back from becoming a truly OO language is also what makes it so appealing. Ever since the introduction of CFCs, there has been the option to use them or not use them. Meaning that you can still code in a CF5 style, if you wish. This, in my opinion, has always been simultaneously, CFML's greatest strength and greatest weakness. I am not saying that you can't use OO patterns within CFML. Just don't expect it to perform 100% like a OO language will. After all, CFML is OO-like, not purely OO. Besides, to quote Adobe again... "CFCs allow, and even encourage, the creation of structured applications." That, after all, is a good starting point for your applications, isn't it?

Posted in Java | ColdFusion | General | ColdSpring | Adobe | Mach-II | Universal Mind | 12 comments

The Next Generation MVC Concept

August 27 2007 by Andrew Powell
Ever since we've had CFCs, we've had a myriad of Frameworks from which to choose. It has always been assumed that the model in the MVC was going to be made up of value objects, data access objects, data gateways, service objects, etc. that are CFCs. Do they have to be CFCs though? Why not leverage the platform that ColdFusion is delivered on and some exiting technologies to build better models?

Read more...

Posted in Java | ColdFusion | Flex | General | ColdSpring | Adobe | Mach-II | Hibernate | 3 comments