Accessibility
Home /

Under the Hood of macromedia.com: Report 1

The Applications on the New macromedia.com

This is the first in an ongoing series of Under The Hood stories which will give technical insight from our engineering leads. Stay tuned for more and send us your thoughts.

What is macromedia.com? The answer might seem obvious ("It's a website!") but macromedia.com is actually a collection of integrated websites that deliver a single user experience. Besides static content areas containing product information, technical support documents, and DevNet, we have an increasing number of dynamic applications on the site. The offerings on macromedia.com have evolved from simple HTML-based applications to full-blown Rich Internet Applications built with ColdFusion MX and sporting Macromedia Flash interfaces.

The nine applications on macromedia.com powered by ColdFusion MX, in approximate order of complexity, are:

  • User groups
  • Tips library
  • Member-only downloads (software updates, whitepapers, and so on)
  • Search
  • Web forums
  • Product registration
  • Trial downloads
  • Membership
  • Exchange

It's interesting to see how these applications differ architecturally. The first five are "traditional" ColdFusion applications with HTML user interfaces. Excluding the web forums application, we're talking about 200 CFML files that contain roughly 30,000 lines of code. The last four in the list are Rich Internet Applications.

Porting Legacy ColdFusion Applications

We originally wrote the user groups and tips library applications in ColdFusion 4.5 and deployed them on our servers on the East Coast. When we later ported them over to ColdFusion MX, we moved them to our West Coast servers and, in the case of the tips library, integrated them with our new membership system (see below).

Our developers based these fairly traditional ColdFusion applications on custom tags, cfmodule, and include files—the primary mechanisms before ColdFusion MX to reuse code and separate logic from presentation. When we modified the tips library application to integrate with the new membership system, we took the opportunity to refactor some of the code with ColdFusion components (CFCs) to improve the structure of the code and lay the groundwork for future enhancements. We also made some minor code changes as we moved the applications from SQL Server to Oracle.

The web forums application is built on FuseTalk and hosted on its own set of servers on the East Coast. To integrate this third-party application with our membership system, we first upgraded the servers from ColdFusion 5 to ColdFusion MX (no changes needed!). Then we integrated our new membership system into the FuseTalk code.

ColdFusion Components as Data Access Objects

Further up the architectural ladder, the member-only downloads application is a rewrite of an application that previously ran on our BroadVision servers. Although it's a relatively simple application, we wrote it so that CFCs create a data access layer of Data Access Objects.

 

Member-only downloads using Data Access Objects

Member-only downloads using Data Access Objects

 

There is one CFC for each type of data entity (effectively, each database table) that the application uses, providing data access and update methods. Using CFCs to separate database access from application logic is a good "first step" in adopting the object-oriented possibilities of ColdFusion MX. It's also a move toward the Model-View-Controller (MVC) pattern by separating the data model from the rest of the application and encapsulating it in components.

ColdFusion Components as Controllers

The search application represents the next step on the evolutionary ladder: It is built around a "façade" CFC that you can call from both ColdFusion pages and Macromedia Flash by specifying access="remote" on the methods. The façade CFC acts as a Controller in that all the client code, whether in CFML pages or a Macromedia Flash client, interacts with the search by going through the façade CFC.

To integrate the core search engine with Google, we first built it in Java and then wrapped it in a CFC to provide a ColdFusion-friendly interface for the façade CFC to call.

 

Search on macromedia.com

Search on macromedia.com

 

ColdFusion Components and Macromedia Flash in Rich Internet Applications

The four Rich Internet Applications on macromedia.com (product registration, trial downloads, membership, and exchange) follow the same basic principles as the member-only downloads and search applications, but on a much grander scale. Each application contains many CFCs, which implement the data access and business logic layers. One or more façade CFCs define the application interface, which is exposed to the Macromedia Flash user interface using Macromedia Flash Remoting.

We easily reused the membership functionality in all four applications. Because we implemented it as a façade which wraps the interaction of various business logic and data access CFCs, the other applications inherited the membership functionality by extending the membership façade. For example, the product registration application façade extends the membership façade by adding methods for serial number validation and recording the registration against the back-office system. We needed fewer than 600 lines of extra code to implement (the server-side components of) product registration on top of the membership system. Similarly, we needed only 800 lines of additional code to implement trial downloads on top of the membership system.

 

Membership extended by registration and downloads

Membership extended by registration and downloads

 

In terms of the MVC pattern, ColdFusion implements the Model and Controller portions using CFCs and Macromedia Flash implements the View, assisted by a CFML page that delivers the initial SWF file and sets up its environment. Furthermore, design patterns are also at work within the ActionScript code behind the View. Several "Singleton" classes act as services or managers for other classes. In particular, a ViewManager class acts as an "Abstract Factory" because it's the central source for any content modules created in the user interface. Another common pattern in the user interface code is "Observer" where various objects can subscribe to notifications of changes—usually to the current View. The "Façade" pattern also provides unified interfaces to subsystems, such as a local shared object and memory management.

Measuring the complexity by code volume, we have about 250 CFML files, of which 100 or so are CFCs (the rest are include files used by those CFCs), containing some 50,000 lines of code. About one-fifth of that code is in the façades used by Flash Remoting. In addition, we have about 300 Macromedia Flash movies containing just over 75,000 lines of ActionScript.

As you move toward more complex web applications, you need structure to manage that increased complexity. It has certainly helped us on the macromedia.com beta. Now it's your turn to leverage the benefits of ColdFusion components to provide that structure as your applications grow. For Rich Internet Applications, the MVC pattern is a great guide to creating a clean separation of presentation, business logic, and data models.

 

 

About the Author

Sean Corfield, Macromedia's director of architecture, brings 20 years of technical and managerial experience in architecture, web technologies, and programming languages. He has expert knowledge in UML, OOA/D, CASE, C, C++, Java, SQL, Broadvision, ColdFusion, and HTML. He relishes a technical challenge both inside and outside of work and healthy technical debates. You can contact him at scorfield@macromedia.com.