Practical Patterns for Everyday Perl - all 23 Gang of Four patterns, implemented in real, runnable Perl.
About the book
Design Patterns in Modern Perl shows how classic object-oriented patterns look in today's Perl. Using core Perl, Moo, and Object::Pad, Mohammad Sajid Anwar builds real, tested examples, helping you choose patterns sensibly and write cleaner, more maintainable code.
Every chapter follows the same shape: the problem the pattern solves, a worked example, complete implementations across three object systems, and the unit tests and benchmarks to go with them.
bless, via Class::MiteMoo, the lightweight modern standardclass / Object::Pad, Perl's newest OO syntaxTable of contents
The three pattern families, laid out the way the book builds them - one package per family, one chapter per pattern.
OOP Frameworks
Below is a chart listing the implementations of each design pattern in the various OOP frameworks. Only four of the patterns were implemented using the experimental class feature.
| Name | bless | Moo | Object::Pad | class |
|---|---|---|---|---|
| Abstract Factory | ✓ | ✓ | ✓ | |
| Builder | ✓ | ✓ | ✓ | |
| Factory Method | ✓ | ✓ | ✓ | |
| Prototype | ✓ | ✓ | ✓ | |
| Singleton | ✓ | ✓ | ✓ | |
| Adapter | ✓ | ✓ | ✓ | |
| Bridge | ✓ | ✓ | ✓ | |
| Composite | ✓ | ✓ | ✓ | |
| Filter | ✓ | ✓ | ✓ | |
| Decorator | ✓ | ✓ | ✓ | |
| Facade | ✓ | ✓ | ✓ | |
| Proxy | ✓ | ✓ | ✓ | |
| Chain of Responsibility | ✓ | ✓ | ✓ | |
| Command | ✓ | ✓ | ✓ | |
| Interpreter | ✓ | ✓ | ✓ | |
| Iterator | ✓ | ✓ | ✓ | |
| Mediator | ✓ | ✓ | ✓ | |
| Memento | ✓ | ✓ | ✓ | |
| Observer | ✓ | ✓ | ✓ | |
| State | ✓ | ✓ | ✓ | |
| Strategy | ✓ | ✓ | ✓ | |
| Template | ✓ | ✓ | ✓ | |
| Visitor | ✓ | ✓ | ✓ |
Reviews
Just by leafing through the table of contents, you realize it's a great book.Mariano Spadaccini - Verified Purchase, Amazon (Italy)
Get the book
DRM-free PDF & EPUB on Leanpub, or a paperback on Amazon.