2013年5月16日星期四

NetTuts.com: How to Write Testable and Maintainable Code in PHP


NetTuts.com has a new tutorial posted suggesting a few ways you can make testable and maintainable code in PHP applications.



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.


There's a few concepts they cover in the tutorial including DRY (don't repeat yourself), working with dependency injection and actually writing the tests with PHPUnit. They start with a bit of code that needs some work and use the tests to help refactor it into something that can be easily mocked (using Mockery).


Link: http://net.tutsplus.com/tutorials/php/how-to-write-testable-and-maintainable-code-in-php

没有评论:

发表评论