O'Reilly logo

Advanced PHP Programming by George Schlossnagle

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

Chapter 8. Designing a Good API

What makes some code “good” and other code “bad”? If a piece of code functions properly and has no bugs, isn’t it good? Personally, I don’t think so. Almost no code exists in a vacuum. It will live on past its original application, and any gauge of quality must take that into account.

In my definition, good code must embody qualities like the following:

  • It is easy to maintain.

  • It is easy to reuse in other contexts.

  • It has minimal external dependencies.

  • It is adaptable to new problems.

  • Its behavior is safe and predictable.

This list can be further distilled into the following three categories:

  • It must be refactorable.

  • It must be extensible.

  • It must be written defensively.

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