Simplicity Is Just The Start Of It
I often start talks on ColdFusion by asking the attendees to play a word association game; I say a single word, and they take turns in responding with a single word—the first word that comes to mind. My word is “ColdFusion”. And the responses? Invariably they say “fast,” “easy,” “rapid,” “productive,” and even “fun.” It works every time.
ColdFusion is indeed all of those things, and that’s what we love most about it. But sometimes its simplicity creates the perception that simple is all there is. After all, how advanced can it be if brand new developers find themselves productive within hours of installation?
And so in this edition of DevNet I’d like to concentrate on some of the advanced technologies and features available to us ColdFusion developers.
More on ColdFusion Components
The addition of ColdFusion components (CFCs) to CFML is probably the most significant enhancement since the creation of the language some eight years ago. CFCs are the mechanism by which you create high-end, scalable, structured, reusable, and highly manageable applications.
For an introduction to CFCs read my article, Introduction to ColdFusion Components. Then, to learn more, read my other article, Using ColdFusion Components—Properly and Hal Helms’ article, Using Inheritance and Composition in ColdFusion Components.
CFCs provide ColdFusion developers with some of the power of objects (and object-based development) while retaining the simplicity of ColdFusion. Check out Dave Friedel’s Building an Object-Oriented User Interface with ColdFusion MX. He explains how you can use CFCs to build user interface abstractions that separate presentation from content while facilitating code reuse.
ColdFusion + Java = The Ideal Application
Much has been written and said about the underlying J2EE engine in ColdFusion. The marriage of ColdFusion and Java introduces all sorts of advanced application development possibilities. A great place to learn more is the ColdFusion for J2EE Developer Center. Combining ColdFusion and Java within your applications gives you the best of both worlds—the power of Java and the productivity of ColdFusion.
Building hybrid ColdFusion/Java applications is not trivial, but it is also far less complex than you might expect. Check out my new book, Reality ColdFusion: J2EE Integration, which I wrote with coauthor Drew Falkman.
In this week’s edition of Developer Center, Drew presents ColdFusion MX and J2EE Hybrid Applications—A Case Study, which walks through one such application in detail. Drew starts with a ColdFusion-oriented Java primer, explains what many of those Java acronyms mean, introduces the MVC (Model View Controller) architecture, and then walks through the hybrid application in detail. You’ll find ColdFusion and Java code working in perfect harmony, and even a web services interface to the application. And of course, you can download all of the code so you can experience hybrid ColdFusion/Java applications for yourself.
Advanced Database Usage
Databases are the cornerstone of almost every ColdFusion application.
And like everything else in ColdFusion, database integration is simple.
That is, if you want it to be. The simplicity of the ColdFusion cfquery
tag (and related tags) masks powerful and advanced database integration
and performance technologies that you can (and should) take advantage
of. Check out last launch’s updated Database
Topic Center. We separated the page into subcategories, to help
you find what you need easier and to highlight four new articles. In
this launch, check out several new database articles.
Caching is a fundamental performance enhancing technology, and ColdFusion supports several forms of caching that you can take advantage of. Macromedia instructor Matt Boles explains both database and data output caching in his article Caching in ColdFusion. If performance is important to you (as I am sure it is) then you’ll want to read this article—you’ll be amazed at the impact of just a few lines of code.
Complex database operations often require that your apps execute multiple related database statements. As a rule, any time you find yourself needing to execute multiple SQL statements back to back, you should evaluate whether a stored procedure would be better suited for the task. Stored procedures are compiled SQL statements (often lots of them with additional flow-control code) that are stored and executed on the database server. Read Sam Neff’s Learning Stored Procedure Basics in ColdFusion MX to get started with stored procedures.
Of course, there are instances when you cannot use stored procedures
(some database don’t support them, some database administrators may
not give you the right permission to create them, and sometimes you’ll
find that they just don’t fit your needs). When this occurs you’ll need
to leverage database transactions to ensure that all your SQL statements
run properly, in order, and as intended. To help you get started with
transactions and the oft misunderstood cftransaction
tag, Figleaf Software Senior Consultant Simon Horwith explains Database
Transactions in ColdFusion. Simon emphasizes that, whenever possible,
it’s preferable to use stored procedures. But he also recognizes that
your apps may need ColdFusion level transactions, explaining them and
the cftransaction tag in detail.
Simple and Advanced Need Not Be Mutually Exclusive
ColdFusion is simple, and always will be. The original premise of ColdFusion was simplicity, and eight years later (even after the introduction of the likes of ASP, PHP, and JSP) ColdFusion is still the simplest way to get the job done.
But don’t be fooled by the simplicity. Beneath the remarkably approachable surface is access to all the power and technology that you could ever need. And, of course, harnessing all of that advanced power through ColdFusion is simplicity itself.
About the author
Ben Forta is the Macromedia senior product evangelist and the author of numerous books, including ColdFusion Web Application Construction Kit and its sequel Advanced ColdFusion Application Development, as well as books on SQL, JavaServer Pages, WAP, Windows development, and more. Ben co-authored the official Macromedia ColdFusion training material, the certification tests and Macromedia Press study guides for those tests, now spends a considerable amount of time lecturing, speaking, and writing about application development worldwide.