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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.28.197