When to Use Custom Tags

 < Day Day Up > 



Now that you better understand how custom tags work, consider some situations in which you should consider using them. As you progress to more advanced levels of ColdFusion development, knowing where and when to use custom tags becomes an increasingly important skill. Custom tags can make complex applications much easier to work on and offer significant time savings when building and maintaining a site. Following are some situations that call for custom tags.

Complex code

Liberal use of custom tags can make complex applications much easier to view and troubleshoot. By breaking complex sections into tags, you create modular applications that are easier to maintain. Well-named custom tags don't usually require any extra explanation, meaning that if another developer replaces you at a later date, he or she can easily understand your code without your help.

Multi-developer environments

When one or more developers will work on an application, custom tags are critical. They allow developers to view a template's source and quickly get the big picture of what's happening in template, without having to wade through the specifics of actions, such as computing tax values, and so on.

Custom tags also allow different developers to focus on tasks suited to their skill level. For instance, in a two-person team consisting of one beginning ColdFusion developer and one advanced, the advanced user might focus on the more complex computations by breaking them out into custom tags. This would allow the beginning developer to work on basic display elements without having to know what's going on within the custom tags themselves. For example, a beginning developer could insert tags, such as <cf_todays_weather> or <cf_banner_manager>, without knowing how the tags work.

Similar functionality in one or more applications

As mentioned briefly in the first section of this chapter, custom tags are ideal for situations in which you need to reuse functionality throughout your site or sites. In addition, if you develop applications for more than one client, custom tags can be enormous timesavers because they enable you to write code once and use it many times.

Implementing common tasks

Custom tags also provide developers with an easy way to share code that has been designed for tasks that are common to many types of Web sites. For example, if the tax computation tag in this chapter were fleshed out to include tax rates for all locales in the United States, it would be valuable not only to you, but to many other developers. You could then share your work with others, either for free or for a fee. Many developers do so, as you'll learn in the next section.

Tip 

New with the release of ColdFusion are ColdFusion Components (CFCs), which are similar in concept to custom tags. However, unlike custom tags, CFCs can be called by a variety of interfaces — not just ColdFusion templates. They can be used to pass information to and from Flash movies, Web pages, and Web services. In addition, CFCs can be called remotely, for example, by clients outside of your local server. You learn more about CFCs and Flash in the sidebar accompanying the final chapter of this section.



 < Day Day Up > 



Macromedia Studio MX Bible
Macromedia Studio MX Bible
ISBN: 0764525239
EAN: 2147483647
Year: 2003
Pages: 491

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net