wblakemd said the following on 01/27/2011 12:46 PM:
> Perhaps using it to solve this problem, will be a good reason start
> making use of it.  Thanks for that.
The concepts behind ColdSpring seem intimidating (DI, IoC, setter
injection, etc), but in all reality what it does is much easier to
understand.  In a nutshell, ColdSpring wires objects together.  You
defined relationships using an XML configuration file.  When you ask
ColdSpring for an object, it first checks a cache to see if it has one
yet and if not uses this wiring plan to give you back a fully wired and
instantiated object back.

The first hurdle to get over is one term that ColdSpring uses the term
"bean".  ColdSpring is a functionality port of a package in the Spring
project (Java).  In Spring, an object == bean while in CFML we typically
use the term bean to describe a business object.  So when using
ColdSpring, when you see "bean" think "object" instead.

Let's look at a simple CS configuration file:

<beans>
    <bean id="showroomService"
        class="spectrum.model.showroom.showroomService">
        <property name="showroomDao"><ref bean="showroomDao"/></property>
        <property name="showroomGateway"><ref
bean="showroomGateway"/></property>
        <property name="udfs"><ref bean="udfs"/></property>
    </bean>
    <bean id="showroomDao"
        class="spectrum.model.showroom.showroomDao"
        parent="baseDaoGateway" />
    <bean id="showroomGateway"
        class="spectrum.model.showroom.showroomGateway"
        parent="baseDaoGateway" />
</beans>

Each "bean" (object) in our model gets a definition.  As you can see,
the ShowroomService has some properties.  This are items are need to be
injected into the service for it to work.  Without ColdSpring in the
picture, you would probably create the ShowroomDao and ShowroomGateway
in the init() method of the ShowroomService.  Instead, the instantiation
of these objects is taken care of by ColdSpring and injected into the
service by using setter methods.  What I just described is called
Inversion of Control (IoC).  Instead of letting the service have
"control" on how objects are instantiated, an outside "provider"
(ColdSpring) takes care of doing that and setting them into the service.

> Duh!  I have recently made the transition from procedural programming
> to using OO and MVC practices that I have gotten so hung up on
> creating objects whenever and where ever I can that I forgot about
> keeping it simple.
A few years back, there was a large debate on whether using an
event-handler for AJAX was ok.  I think largely it's been resolved but
it works and simple.
>> Lastly, you could build out an M2 endpoint for your AJAX to talk to
>> (like a REST endpoint).
> One thing at time. ;-)  I am just starting to get comfortable with OO
> and MVC, MachII and now ColdSpring.  REST is another one of those
> things that I have 'heard' about and even 'read' about but do not
> fully understand.  Got any resources that can give me an easily
> digestible overview of REST, what it does, how it helps, and why I
> need/should use it?
Yeah, I thought about leaving it out just because it really is a one
thing at a time process.  But then I felt bad not to disclose it as an
option for the future (plus those coming in from Google).

We have a great list of REST resources on the wiki:
http://trac.mach-ii.com/machii/wiki/RESTResources

My favorite introductory resource is How I Explained REST to My Wife:
http://tomayko.com/writings/rest-to-my-wife

Also, Doug Smith has a great one hour presentation about REST and how
use the M2 REST endpoint (link and code in the resources section above).

As for books, I've almost done reading both of the book listed on the
resources page.  They are both great.  The cookbook is more for solving
problems (doesn't explain REST) while the RESTful Web Services does a
great job of explaining all ins and outs of REST.

> Thanks again Peter!
Glad to be of how when I can.

-- 
You received this message because you are subscribed to Mach-II for CFML list.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/mach-ii-for-coldfusion?hl=en

SVN: http://svn.mach-ii.com/machii/
Wiki / Documentation / Tickets: http://trac.mach-ii.com/machii/

Reply via email to