Archive for January, 2007

Cairngorm Code Generation

I’m increasingly questioned about how much code-generation we employ when we’re developing our own solutions upon Cairngorm; let me address this point with a look to the past, the present, and the future.

The Past – From UML to Code Generation for the Mother of Cairngorm

Way back in the past (1999-2000 timeframe) I was a huge advocate of UML and roundtrip engineering; in fact some of my now Adobe Consulting colleagues were colleagues in a past-life, where we were ardent users of the Together UML tool for Java.  Together were acquired by Borland, and Together UML now ships with Borland IDEs I believe.

Around the same time I began to sip from the agile firehose, I became less interested in UML modelling and model-driven development techniques.  It was around this same time that I first was exposed to the Core J2EE Design Patterns from the Java One presentations by Alur, Crupi and Malks, and developed my first architectural framework using these patterns in Java.  We called the framework "Mesh" (as in a wireframe mesh for the application, remember this was before struts, but same idea) and found ourselves laboriously writing lots and lots of repetitive "handle-turning" code.  Mesh was the mother of Cairngorm I guess, in that Cairngorm took a subset of the design patterns that we leveraged in the Java world.  In Cairngorm, we discarded the Data Access Object (DAO) pattern,  the Business Delegate became a much simpler facade onto server-calls, as opposed to an almost object-to-relational bridge between the Java value-object world and the JDBC PreparedStatement and ResultSet world for Create, Read, Update and Delete methods.  And of course, the value objects mapped very closely to the underlying database structure, as the DAO pattern adapted tables to objects.

We found that any story (feature/use-case) we picked up for development would inevitably be a bottom-up development of "add/augment a database table, update the value object definition, create a new DAO if it was a new table or view on the database, or tediously update lots of SQL queries and iteration over ResultSets if we were simply adding columns to a table, write new methods on the DAO, and then write new methods on the appropriate Business Delegate class to call the new DAO methods, adapting ResultSets into value objects and value object graphs. Only then would the story-specific fun begin, as we implemented Command classes and JSP to render the view. Boring, boring, boring.

With all this tedium, I turned to code generation of the value objects by JDBC introspection of the database metadata (creating value objects per table, and attributes on value objects according to columns in the table).  I’d then code generate the DAO classes, all the CRUD operations and queries, and the business delegate methods for each DAO method.  It was all very crude (perl initially, Java eventually) code generation, and inevitably we’d step in and do some hand-coding or optimisations to the code anyway, which meant we then didn’t want to rerun the codegen (it wasn’t as clever as being round-trip code generation).

I’d argue that with all this tedious VO, DAO and Business Delegates upon a database tier, the effort for code-generation just about paid off for us.

If you’re interested in this kind of approach, from database through Java-tier all the way to creating client-side code (not Cairngorm based) and a view, the team at Farata Systems have created DAOFlex that will do exactly this kind  of code generation, much more elegantly than my home-brew approach at the time as well   There’s an article on Adobe devnet that will get you started.

The Present – Adobe Consulting on Cairngorm Code Generation

Right now, I’d say that the amount of code that we would typically usefully generate hasn’t really justified the effort; code-generation is a decision that a technical architect will make on a project by project basis, but it certainly isn’t in our arsenal of practice-wide techniques that we apply to each and every project.

Peter Martin did make some attempts with the XDoclet 2 work that he did, building on some work by Joe Berkowitz of Allurent.  As you can see from his blog entry, it was a lot of work to create value objects only, which in the grand scheme of our typical projects, don’t account for a whole host of development effort and time to maintain.

So in summary; right now we’re not employing a great-deal of code generation and don’t feel that we’re suffering in productivity because of it.  Those coming from a Ruby on Rails background are often impressed at the ability to automagically generate so much scaffolding for CRUD type applications – I think the DAOFlex approach may work for you here, and remember we’re never necessarily advocating Cairngorm for your simpler Flex applications anyway.  Someone asked me in blog comments recently whether Cairngorm and Flex could be more complex than Ruby on Rails with AJAX, and I guess sometimes it can be.  However, those are two poles of a spectrum, and in-between there are a number of much-simpler non-Cairngorm Flex approaches that can be taken to rapidly deliver simple applications.  There are times when i think you shouldn’t use Cairngorm.

I guess under the present tense, I would like tomention the work that has been done by Eric Feminella in a project he has called Cairngen.  Eric’s motivation is to remove the repetition associated with creating Events to be registered with the Front Controller and their corresponding Command classes, by creating the notion of a "sequence" that can code generate stub classes for the Event and Command.  Cairngen will also make it quicker for you to start a brand new Cairngorm Flex project, by creating all the project structure, folders and template classes for a skeleton Cairngorm project.  Cairngen is a server-based solution, leveraging PHP and AMFPHP to manage the code generation from templates – it may work for your workflow, and is definitely worth checking out on Eric’s blog.

Though I’ve never used the product, I noted that WebOrb is now also generating Cairngorm code from templates as well, so that may be worth checking out if you’re using WebOrb already.

The Future – Integrating Cairngorm more tightly into Flex Builder workflow

I spoke in my last blog entry, that our Adobe Consulting team are constantly balancing client and project committments, with practice and community committments to deliver best-practices, guidance and productivity tools for those using the same tools and technologies that we do every day.

As we focus on Cairngorm 3, we’re also very focussed on enhancing the workflow for Flex developers who are working within FlexBuilder.  We’ve a number of ideas that are more than simply push-button Code Generation that will yield the flexibilities and benefits that we consider from working with a Cairngorm architecture, and that will furthermore leverage the consistency and predictability of Cairngorm Flex development to assist developers in building applications with Cairngorm and Flex.  That was a hell of a long sentence.  It’s still very early days in our development, so we have nothing to preview or share at present … but hopefully that gives a little insight into where we’re going in terms of developer productivity around Cairngorm.  I’m sure the consultants who have this work as their practice targets will release more information, or even previews, as and when they have something ready to share.

If I’ve missed any other code-generation or general Cairngorm productivity tools in my roundup, please feel free to add them here in the comments. 

But hopefully that shares the current working practices within Adobe Consulting, and gives you some confidence in your own approaches.

AC2k7 – Flex2 and beyond, LiveCycle 8, Apollo, Cairngorm 3, Methodology and Madness, Design Led Innovation and more !

I promise this will be the nerdiest blog title I’ll have all year.  It was almost AC2k6++.  2006 has been a tremendous year within Adobe Consulting. I want to kick-off 2007 with some retrospective of how far we’ve come in the last while with all things RIA, and then take a look forward to my thoughts on what’s in store for us in our chosen field in 2007, while sharing some of the topics and thoughts that I hope to elaborate upon in the year ahead.

Running my own company with Alistair trying to convince the enterprise world of the need for more engaging user-experiences and then assuring them that they could be delivered upon the Flash platform, sometimes seems like only yesterday (warning – self-assessment tax deadlines in the UK are end of the month) but most times feels like a past life.  In 2006, we really seem to have come so far in the world of Rich Internet Applications.  My key observation going into 2006, was that I was spending less and less of my time advocating "experience matters" within organisations.  That which was not yet self-evident the years before, was now the starting point for conversation – so much of my evangelism efforts this year have been less focussed on why and more focussed on how an organisation can be more effective, or more impactful and successful, through a richer user-experience. One doesn’t have to look hard now to find the importance of user-experience, and the value of user-experience focus, as core message from vendors, or core requirement from customers.  It’s interesting to see how often the "experience matters" rhetoric resurfaces in a same-but-different guise.

Experience really matters, I guess.

I’m confident that 2007 is going to be a year in which we really see organisations striving to thrive and survive online through innovation – innovation in their online service delivery through a well conceived and expertly crafted experience Design.  Design with a big d ?  I’ll be coming back to that in future blog posts.

I talked just there about innovation in service delivery; while it’s true that Rich Internet Applications can deliver much more effective user-experiences upon existing service infrastructure ("on the glass"), true innovation can be applied "behind the glass" as well, seamlessly optimising the underlying orchestration of business processes that the user-experience is exposing.  As easy as it often can be to point fingers at a particularly memorable bad online experience, often that experience is the necessary surfacing of unnecessary underlying madness. 

When I tried to transfer money using my online bank to pay for some home improvements, it turned out that in the history of online banking with that account, I’d already paid 20 people money (that’s a lot for a Scottish guy) online, and I wasn’t allowed to pay 21.  Ridiculous – but I deleted someone that I had no intention of giving money to again (that’s not so tough for a Scottish guy) so that I could add a new payee.  Now I have 19 previous payees, and I add the 20th one … I’m still not allowed.  Same error message.  I’ve paid too many people for a Scottish person, please contact customer services with a good explanation.  I guess the payee I deleted is marked as deleted, but not physically deleted from the database, because there’ll be some referential integrity violated if they perform a physical SQL delete.  Listen to me for a minute — should I need to be excusing the online bank’s behavior with Relational Database theory ? 

Of course I shouldn’t, the offline inmates are off running the online asylum.

This story reinforces my point and ambition. As much as we should continue to innovate in the quality of user-experience that we are willing to deliver to end-users, in this era of service oriented architecture we should also ensure that services are designed and orchestrated as such; that they are not allowed to become the tail that wags the dog. 

There is equal opportunity for us to focus on improving the back-end, unseen, over-the-wire and behind-the-glass services, whether that be through elimination or optimisation of paper-based processes or perhaps improving the workflow necessary to fulfil an apparently simple task.

Have you ever thought of just how much effort goes on behind the scenes when you click the "buy now" button on iTunes and a minute later you have an entire album, plus track listings, plus artwork on your portable MP3 player ?  I’ll be talking about exactly these kind of beautifully Designed, seamlessly executed, insanely great solutions in much more depth in this blog throughout 2007.

That’s why I’m particularly excited this year about the LiveCycle 8 technology, and the kind of solutions that Adobe Consulting are increasingly delivering for our clients, or helping our partners deliver, by leveraging LiveCycle services with rich Flex user-experiences.  I can’t wait to talk more about the innovations that are possible when these 2 worlds collide.  Throw Flex Data Services into that mix, and season with a little forthcoming Apollo goodness, and 2007 is going to be an opportunity for us to engage in the delivery of some truly innovative Design-led solutions.  Design had a big d there again.  Sorry.  Habit.  I’ll explain later.

Technology-wise, I look forward to blogging ( more … we all have that as a resolution this month, right ?) on the continuing innovation of enterprise products from Adobe; from what’s coming in LiveCycle 8 and Apollo, to current and future Flex and Flex Data Services goodness.  And more ?

The Adobe Consulting team will continue to share what we consider best-practices with our technologies, gleaned from the projects we’re working on with clients worldwide, through our blogs, through devnet, through conferences such as MAX, and through whatever other means you consider valuable to you.  It’s a big part of our remit to ensure that we’re sharing our insights and experiences to help ensure that you are more successful, more easily, in your own implementations.  We spoke a little at MAX about Cairngorm 3, and I look forward to progress there in 2007. 

One of my roles within Adobe Consulting is to ensure that the consultants in my part of the team are focussed not just on delivering value to clients through their day-to-day consulting engagements, but are also delivering value to partners and the community at large, by focussing time and energy in internal technology initiatives that have wider value to a wider audience. Some of the AC2k6 contributions are below:

Our goals are locked down for the first half of 2007, and I look forward to that work being completed and released in the wild – not just around Flex, but around Apollo, LiveCycle and all manner of other technologies, best-practices or productity enhanching tools.

I also intend sharing much more insight through this blog into the approach we take to delivering solutions, from inception through to delivery.  Software methodology.  Consulting approach.  How do we plan for innovation ?   How do we deliver innovation ? How do we position the value of an RIA engagement ?   How can we ascribe value to delivery of an improved user-experience ? How do we staff a project – what are the roles necessary to deliver an Enterprise RIA solution, and what workflow, what assets, what deliverables, what handovers and what cross-over exists between these roles ?   How do we blend cutting-edge Design with cutting-edge delivery  ?  How do we take agile software approaches to defining and delivering user-experiences, and harmonise them with the needs of our User Experience consultants to ensure they gain the insights necessary for innovation ?

In many ways, these state of the art technologies with which we share passion, are our bread and butter. 

The technologies are the easy part. It’s what we do with them that’s the difficult part.

As always, I look forward to seeing what you’re doing with them; and as best I can look forward to showing you what we’re doing, and how we’re doing it.

And 2007 will be all the richer for it.