About the Book: Learning PHP Design Patterns: Object-Oriented Programming for Dynamic Projects Build server-side applications more efficiently-and improve your PHP programming skills in the process-by learning how to use design patterns in your code. This book shows you how to apply several object-oriented patterns through simple examples, and demonstrates many of them in full-fledged working applications. Learn how these reusable patterns help you solve complex problems, organize object-oriented code, and revise a big project by only changing small parts. With Learning PHP Design Patterns, youll learn how to adopt a more sophisticated programming style and dramatically reduce development time. Learn design pattern concepts, including how to select patterns to handle specific problems Get an overview of object-oriented programming concepts such as composition, encapsulation, polymorphism, and inheritance Apply creational design patterns to create pages dynamically, using a factory method instead of direct instantiation Make changes to existing objects or structure without having to change the original code, using structural design patterns Use behavioral patterns to help objects work together to perform tasks Interact with MySQL, using behavioral patterns such as Proxy and Chain of Responsibility Explore ways to use PHPs built-in design pattern interfaces Contents: Easing into the Fundamentals of Design Patterns Chapter 1 PHP and Object-Oriented Programming Chapter 2 Basic Concepts in OOP Chapter 3 Basic Design Pattern Concepts Chapter 4 Using UMLs with Design Patterns Creational Design Patterns Chapter 5 Factory Method Design Pattern Chapter 6 Prototype Design Pattern Structural Design Patterns Chapter 7 The Adapter Pattern Chapter 8 Decorator Design Pattern Behavioral Design Patterns Chapter 9 The Template Method Pattern Chapter 10 The State Design Pattern MySQL and PHP Design Patterns Chapter 11 A Universal Class for Connections and a Proxy Pattern for Security
Raramente capita di mettere il minimo dei voti a un libro O'Reilly...
Le spiegazioni sono quasi incomprensibili, le frasi inutilmente convolute, spesso messe in forma passiva o negativa (o addirittura con doppie negazioni), al punto da rendere stressante la lettura.
Gli esempi sono assurdi. Uno su tutti: usare un observer per propagare le modifiche a tre versioni del layout, quando si sarebbe potuto usare lo stesso esempio per uno strategy. Forse hanno senso in un altro linguaggio, ma non in PHP, e visto che si chiama "Learning PHP Design Patterns" e non "Learning Design Patterns", sono totalmente sbagliati. Altri sono talmente complicati che non si capisce nemmeno come funzionino. E la spiegazione è messa al contrario: a parte una inutile descrizione troppo astratta, prima mette il codice, e poi FORSE spiega perché fa certe cose. Non sempre. A volte nemmeno lo spiega.
This book is only an "OK" introduction to these topics. Luckily I have a skilled colleague who was able to to further explain/clarify many of the concepts. The biggest problem with the book is that often the examples are very poor and don't really drive home the salient points. There are also a few example where the author presents too much detail of a possible implementation, including HTML & CSS for a form, which I found completely unnecessary for understanding how a pattern might be used for a problem. The book did at least spark my interest in learning and understanding more about using patterns properly.
The book is probably OK, but during the fifth chapter I began questioning the use of object-oriented paradigm itself. I probably should disclose that I love Scala and JavaScript which both use a bit different paradigms, object-functional and Object-linked-to-other-objects with functional capabilities.