Unit 20.1. Designing Code Structures
Reusing Code
You should be thinking as you design your code architecture of how to avoid code duplication. A good example of code reuse is discussed in Chapter 18, “Web Tips and Techniques.” The HTML form code for inserting and updating a student, as well as the JavaScript form validation code, is exactly the same. For insert, the form is empty and the student ID is unknown, while for update, the form fields are prepopulated for the selected student. If the form needs to be changed, then only one procedure has to be changed, in only one place. Whereas, if two separate procedures were created (one for insert and one for update), then the form would have to be revised in two procedures. This increases the ...
Get Oracle® Web Application Programming for PL/SQL® Developers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.