News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Josh Adell's Blog:
Command Invoker Pattern with the Open/Closed Principle
January 16, 2012 @ 10:04:42

In a response to a recent post on DZone.com about the "Open/Closed Principle" Josh Adell has posted an example of a " flexible and extendable command invocation solution" implementing this SOLID idea.

Let's overcome some of these issues [with only being able to extend the invoker class and that the invoker needs to know how to create commands], and also make the code even more extensible. I'll use a simplified command invoker to demonstrate.

His code is included - the creation of a "Command" interface and two comments that implement it: "HelloCommand" and "PwdCommand", each with "register" and "execute" methods. His "Invoker" class then only needs to be told how to map these commands and the "register" is called as they're needed. You can find the full example code for this invocation example in this gist.

0 comments voice your opinion now!
command designpattern invoke open closed principle solid tutorial


blog comments powered by Disqus

Similar Posts

System Architect: Integrate PHP application with Solr search engine

Matthew Weier O'Phinney's Blog: Applying FilterIterator to Directory Iteration

Lars Strojny's Blog: Dependency Injection Container Refactorings, Part One

Shameer's Blog: PHP 5.3 : Practical look into Lambda functions and closures

Zend Developer Zone: An Introduction to the Art of Unit Testing in PHP


Community Events

Don't see your event here?
Let us know!


symfony2 release language configure php7 voicesoftheelephpant podcast example application series interview framework introduction laravel library api conference opinion community performance

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework