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 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.