Chapter 8. Eliminate Duplicate Code: Sharing is caring

image with no caption

Umbrellas aren’t the only thing that can be shared. In any web application you’re bound to run into situations where the same code is duplicated in more than one place. Not only is this wasteful, but it leads to maintenance headaches since you will inevitably have to make changes, and these changes will have to be carried out in multiple places. The solution is to eliminate duplicate code by sharing it. In other words, you stick the duplicate code in one place, and then just reference that single copy wherever you need it. Eliminating duplicate code results in applications that are more efficient, easier to maintain, and ultimately more robust.

Get Head First PHP & MySQL now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.