Best PracticesCreating Code Snippets from Custom Code


It's happened to the best of us. You write a complex piece of code to perform a special function and it works beautifully. A while down the road, you find yourself needing the same functionality and you can't seem to remember which page it was that performed the function, so you spend valuable development time racking your brain to find the code. This scenario is the exact reason why it's so important to take advantage of the snippets functionality of Dreamweaver. By adding the custom code you create to the snippets library, you end up creating your own customized code library that is organized to fit your needs.

I spent a half hour a few weeks ago searching for a chunk of VBScript code that I had created to convert MS SQL Timestamp fields into epoch numbers (the number of seconds since 01/01/1970). I needed the function to interface one of my web applications with a help desk application and couldn't seem to remember where and when I used the function. After spending quite a bit of time searching (and wishing that I had created a snippet), I finally found the code and immediately placed it into my code library.

No matter how obscure the code, no matter how tied to a specific client or website it might seem to be, it's still a great idea to add all your custom code to the snippets panel for future reference.

Tip

Don't worry that your code library will be limited to use on a single computer. With Dreamweaver, you can export your site settings and the snippets that go with it by choosing Site, Export from the main menu. After you export the site to a single file, you can transport that file to a new computer and import the site by choosing Site, Manage Sites from the main menu and then clicking the Import button.




Special Edition Using Macromedia Studio 8
Special Edition Using Macromedia Studio 8
ISBN: 0789733854
EAN: 2147483647
Year: 2003
Pages: 337

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