Servicing so many…
September 14, 2007
ColdFusion CFCs are gods gift to web development. Yes, there are security concerns, but with a good design you have at your disposal a tool for creating an interface, web method, web service, well defined objects and more. I love to create a Service Layer and connect a Flex Application to it because I know how much work I’m not doing.
My service layers are simply interfaces (as I believe most are). No logic really, just a remote interface to the business layer and some security. If I’m writing a external app there are more considerations than an internal. The external remote service calls are wrapped up in a RequestDTO Object of some kind and they payload a security context dto of some kind. In this case the Service Layer will be breaking up the composite DTOs and accessing various BI calls to complete a process. This is a pattern called Session Facade and it relies heavily on the choice of DTO design.
If I didn’t explain the importance of DTOs then I should have. A Data Transfer Object (sometimes called ValueObject) is an object defined by its use more then by the pieces of data that make it up. A ShoppingCartDTO will have an array of Items, a user maybe and various other configurations but the shopping cart looks nothing like that in the database (or even the abstraction layer). The Services layer is going to deal with incoming requests, received as DTOs and interact with the BI layer passing along DTOs and getting DTOs back. What is the difference between the DTOs and DAOs? Well with EJBs sometimes there is no difference (not a good design to me). Mostly the difference is in simplifying the object to work for the UI and the services layer without carrying around anymore information then necessary. A DTO also gives you the opportunity to composite DTOs and configuration properties to transfer a complex set of objects as a single object. Another handy function: it gives Flex (a separate technology from ColdFusion and Java) the ability to use native ActionScript objects as proxies for middleware objects in both directions.
With these DTOs available to Flex as objects, and not just graphs of simple properties – very strict definitions can be written on the Flex side. This fits in very nicely with an MVC framework like Cairngorm. With well defined objects, views can be bound to DTOs instead of having to muddy the waters with hundreds of listeners.
more on a later date (hopefully with examples)…