Sounding good. If I'm following you correctly, I suggest you use a facade to
expose the API, have your processForeignOrder() method in there and exposed
as a 'web service'.  This method can decide which gateway instance to call
via a Factory.  Each Gateway you have will follow a contract on methods it
has using a interface, something like ICRMGateway.  Thus your Factory has no
clue of your implementation, it just returns a ICRMGateway and your
processForeignOrder()
calls methods on it without caring which Gateway it is.  Sounds like you
will need a property in OrderObject specifying which foreign system was
used, pass this property to your factory method so it can determine which
implementation to return.

Note that ONLY your facade CFC will have remotely exposed methods, all other
CFCs will not.

Make some sense?  This is following the factory pattern here
http://en.wikipedia.org/wiki/Factory_method_pattern.

Douglas Knudsen
http://www.cubicleman.com
this is my signature, like it?


On Sat, Mar 26, 2011 at 5:41 PM, Clarke Bishop <cbis...@resultantsys.com>wrote:

> I’m still working through this project, but I’ve made a lot of progress and
> though I’d give you an update. It might help someone else!
>
>
>
> First, here are some good resources I found on Object-Oriented Coldfusion.
> The first link was especially helpful.
>
>
> http://www.iknowkungfoo.com/blog/index.cfm/2007/8/22/Object-Oriented-Coldfusion--1--Intro-to-Objectcfc
>
>
>
> http://www.objectorientedcoldfusion.org/
>
>
> http://www.bennadel.com/blog/1379-Hal-Helms-On-Object-Oriented-Programming-Day-One.htm
>
>
>
> Now, here’s where I decided to go:
>
> ·         I’ve got a shoppingCartGateway that retrieves all the needed
> data from the shopping cart system.
>
> ·         shoppingCartGateway then creates and returns an OrderObject
> populated with all the shopping cart data.
>
> ·         I pass the OrderObject into the CRMGateway that stores
> everything in the CRM system.
>
>
>
> The OrderObject is just a value object, but it’s format is consistent, so I
> can switch out either of the gateways.
>
>
>
> I’m still working through how to best apply the business rules. I think
> I’ll cfinclude them into the CRMGateway. It’s just a bunch of If/Then logic.
>
>
>
> I’m sure I broke some OO rules along the way, but my new approach feels
> cleaner and more workable. Of course, I’m still open to suggestions if
> anyone knows a better way!
>
>
>
>    Clarke
>
>
>
> *From:* Clarke Bishop [mailto:cbis...@resultantsys.com]
> *Sent:* Wednesday, March 23, 2011 12:50 PM
> *To:* discussion@acfug.org
> *Subject:* Sync'ing systems via web services
>
>
>
> I have a project to sync two systems via web services. The objective is to
> get customer data and orders from a shopping cart, and then transfer the
> data into a CRM system. It's a one-way transfer now.
>
> There will be different shopping carts systems, different CRM's, different
> business rules for different companies, and sometimes slightly different
> data elements. For example:
>
> Company A might use Magento shopping cart with CRM A.
> Company B might use Volusion shopping cart with CRM A.
> Company C might use Magento shopping cart with CRM B.
>
> To sync the data, this is what needs to happen:
>
>    1. Periodically, check the shopping cart for any new orders.
>    2. For any new order get additional information out of the shopping
>    cart (Some data isn't available via the order API call)
>    3. Create or update the info in the CRM.
>    4. Run a set of business rules based on the order and set fields or
>    flags in the CRM.
>
> I'm trying to create the right abstractions that make this manageable. I
> have a procedural version, but I want to divide up the code to make it
> easier to manage and enhance. Right now, I have to copy the code and make a
> version for each Company -- Messy!
>
> I was thinking I could have a shoppingCartGateway.cfc and a CRMGateway.cfc
> to manage CRUD for each shopping cart and CRM. I'm hoping to be able to
> switch out the shopping cart gateway to handle different shopping carts, and
> then have a one, consistent order object or structure.  Then, I can sync the
> order object with any CRM via the CRM gateway. I'd like to decouple the CRM
> from the shopping cart to handle all the variations.
>
> I'd need an orderObject.cfc to hold all the order and customer data. Or,
> this could possibly just be a big Struct, or I could store the order data in
> a database. I expect, it will take several gateway calls to fully set all
> the data values in the orderObject, so I need a way to keep the data around
> and get it organized.
>
> My question is what's the best design architecture? I'm writing this to
> clarify my thinking and I'm also hoping some of you will have some good
> ideas or pointers for me!
>
> I'm having trouble thinking about which object should be responsible for
> what!
>
>    - Does the orderObject create and use the shoppingCartGateway.cfc as a
>    service to initialize itself?
>    - Or, do I have a separate sync.cfc that just uses the orderObject as a
>    value object, gets the data from shoppingCartGateway.cfc and stores it in
>    the orderObject?
>    - Or, is there a better way of thinking about this that I'm missing?
>
> I also need a way to handle business rules between Company A, B, and C. For
> example, Company A may sell coffee and wants the CRM to reflect whether this
> customer like mild or strong coffee based on the products the customer
> bought. Then, they can notify the customer of a new kind of coffee the
> customer might like. Company B wants their CRM to show the number of orders
> from each customer so they can use this to send special promotions to their
> best customers.
>
> All the data that's needed to apply the business rules is in the order
> information. What I'd like to have is a clean way to organize the code so I
> can keep Company A's and Company B's business rules separate. I thought I
> might use inheritance and just extend based on the company. But, extend
> which object?
>
> Thanks for listening and for any ideas!
>
>    Clarke
>
> -------------------------------------------------------------
> To unsubscribe from this list, manage your profile @
> http://www.acfug.org?fa=login.edituserform
>
> For more info, see http://www.acfug.org/mailinglists
> Archive @ http://www.mail-archive.com/discussion%40acfug.org/
> List hosted by FusionLink <http://www.fusionlink.com>
> -------------------------------------------------------------

Reply via email to