O'Reilly logo

Designing Active Server Pages by Scott Mitchell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Practicality of Reuse

Earlier in the chapter, the three general steps of form creation were outlined as follows:

  1. Create an HTML form with the proper form fields, complete with client-side form validation.

  2. Create a form-processing script and add the needed code.

  3. Add server-side form-validation code to the ASP page created in Step 2.

In this chapter we examined code that took advantage of the repetitive nature of Steps 1 and 3. How practical, though, is code reuse? The answer depends on how many times we are going to repeat Steps 1 and 3. Since there is such a high initial cost in developing robust, generic, reusable code, it may not seem sensible to proceed with such code development unless you plan on reusing the code extensively.

I strongly suggest that you strive to make all of your code as reusable as possible. While this may seem time-consuming and a bit overzealous, it will be beneficial in the long run. For example, creating a reusable form class, as we did in this chapter, will save time when creating a form in any project! Once the reusable form-generation and validation code has been written, the timesaving benefits will be automatically included for all future projects using forms.

To summarize: although writing reusable code may seem like a great deal of initial overhead—and therefore overkill for small projects—the benefits of code reuse almost always extend far beyond the current project. For this reason, strive to apply code reuse methodologies to all of your projects. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required