Tuesday, 22 May 2007

PHP in Action book review

Over the last few days I got the chance to skim through the upcoming Manning release "PHP in Action: Modern Software Practices for PHP" by Dagfinn Reiersøl et al. The reviewed book is separated into four main parts, covering lots of interesting topics in a good and fluent writing style.

The first part covers basic tools and concepts applied to PHP, which includes software design principles, object-oriented guidelines and the use of design patterns. If you are a continuous reader of specialized publications you might have read or heard of most of them, but the authors know always how to relate them to the PHP language. Were suitable the object-oriented concepts and guidelines are compared to the JAVA language, to support the learning process by showing similarities and varieties, without awaiting the reader to be an JAVA expert.

The second part addresses the approach for developing and designing more reliable web applications by applying TDD(Test-Driven Development) as a learning, design and quality assurance tool for the development process. It starts with traversing through the TDD cycle by using examples which are based upon the SimpleTest framework. If you're favouring the use of PHPUnit the provided knowledge can be easily transformed and might encourage you to get a feeling of the TDD flow while transforming it. Further on more advanced testing techniques like using mocks and stubs are covered for the isolated testing of components. The outlined 'Red, Green and Refactor' cycle is closed by examples of basic refactorings and other cataloged refactorings(i.e. Replace Conditional with Polymorphism) in a PHP manner. Finally this part of the book is rounded off by sketching the refactoring of procedural code towards object-oriented code and how to test your applications front-end via web tests supported by the SimpleTest framework.

In the third part the main focus is on the specifics of web presentation and user interfaces. The authors show how to achieve the desirable separation of presentation and the main domain logic by using several techniques reaching from plain old PHP to template engines and to the adoption of XSLT in combination with some general presentation logic patterns(Composite View, Two Step View). Thereafter a switch is made to illumine the architectural MVC pattern and how it can be used to identify commands and actions made within the user interface and how to map these to the application domain logic. In this regard classic PoEAA patterns like Page Controller and Front Controller are covered. The part is finally closed by thoughts and insights on input validation and form handling in context of possible strategies, stumbling blocks and implementation solutions.

The last part of the book deals with object-oriented data access, reaching from database abstraction, to overcoming the object-relational impedance mismatch, to the generalizing and generation of SQL statements and to supportive design patterns like Data Access Object and Active Record.

The point I liked most about this book is how it sets previous 'heavy impact' publications like Patterns of Enterprise Application Architecture and Refactoring: Improving the Design of Existing Code in relation to the PHP programming language. This might save you some mental translation work on covered areas and serve as an entry point for further research. I'd like to recommend this book as as very valuable reading to anyone who has already mastered the fundamentals of software development with PHP and is looking for further input to push its own development fitnesse and its way to develop 'not-your-average' web applications.

No comments: