How to Write Testable and Maintainable Code in PHP

Begin structuring your code to achieve testability and maintainability

Frameworks provide a tool for rapid application development, but often accrue technical debt as rapidly as they allow you to create functionality. Technical debt is created when maintainability isn't a purposeful focus of the developer. Future changes and debugging become costly, due to a lack of unit testing and structure. Here's how to begin structuring your code to achieve testability and maintainability – and save you time.

 

We'll Cover (loosely)

  • DRY
  • Dependency Injection
  • Interfaces
  • Containers
  • Unit Tests with PHPUnit

Let's begin with some contrived, but typical code. This might be a model class in any given framework.

Lubov Cholakova

Lubov CholakovaLubov has been with DMXzone for 8 years now, contributing to the Content and Sales departments. She is bringing high quality content in the form of daily blog updates, reviews, tutorials, news, newsletters,update emails and extensions' manuals. If you have a product that needs publicity or any other questions about the entire DMXzone community, she is the one you can contact.

See All Postings From Lubov Cholakova >>

Comments

Be the first to write a comment

You must me logged in to write a comment.