 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Josh Adell's Blog: Command Invoker Pattern with the Open/Closed Principle
by Chris Cornutt 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.
voice your opinion now!
command designpattern invoke open closed principle solid tutorial
DZone.com: Open/Closed Principle on real world code
by Chris Cornutt January 13, 2012 @ 09:05:53
In a new post to DZone.com Giorgio Sironi talks about the "open/closed principle" in software development and shows an example based on the design of the PHPUnit_Selenium project.
This article shows an example of how the application of the Open/Closed Principle improved the design of a real project, the open source library PHPUnit_Selenium. These design concepts apply to every object-oriented language, including Java, Ruby or even C++. The Open Closed Principle, part of SOLID set, states that software should be open for extension and at the same time closed for modification.
He starts with a little background on the project, pointing out that there's a Session object it uses for all of its testing with a magic "__call" method that handles any kind of method call to the object. This method has issues (dependencies, strict requirements for use) but can be refactored according to the Open/Closed idea to set up an array of anonymous functions that can be called as a "command". Examples of these types of classes are also included (one for the "click" action on a button and another for getting the current location).
voice your opinion now!
open closed principle solid design command phpunit selenium
PHPMaster.com: Understanding the Command Design Pattern
by Chris Cornutt January 03, 2012 @ 08:25:29
On PHPMaster.com today there's a new article introducing you to the Command design pattern and looking to help you understand its use a bit better.
The majority of [cell phone] users have opted to receive an email, but a significant number are now opting to receive the notifications via SMS. Here's the problem: How do you send a message via two different channels to both groups of users? The logical approach would be to split the users into 2 groups, email recipients and SMS recipients, which would involve running 2 different queries and sending the codeword to each group separately. Using the Command Pattern, which I will introduce you to in this article, you can send the message to both groups of users in a single process.
He uses the message queue he mentioned as an example - showing how you can can queue up different kinds of objects (actions) based on a common interface into the same process. He creates a "DailyAlertEmail" and "DailyAlertSMS" classes, both with a "send" method. The settings for these are then pulled from a database and the "execute" method on the "MessageQueue" class is called to loop through them, calling "send" to do that work.
voice your opinion now!
command designpattern tutorial message queue sms email
Gonzalo Ayuso's Blog: My VIM configuration for PHP development
by Chris Cornutt January 03, 2011 @ 13:50:35
In a search for his perfect development environment (note "his" not "the") Gonzalo Ayuso has taken another look at vim in a new post to his blog with some handy plugins and commands he's found so far.
Keeping on with my continuous search for the perfect IDE I've resumed my fight against VIM. As someone told me the learning of vim is a road of pain. It's something like going to the gym. We known that going to the gym is good and healthy but it's hard and painfully especially at the beginning. The learning curve of vim is hard. [...] VIM is not my default IDE yet. I hope to swap to VIM soon but I feel myself slower when I code comparing with Netbeans or ZendStudio, and slow means less productive but I also feel if invest more time vim can be really productive.
He points out these plugins and commands:
- NerdTree
- the "buffer explorer"
- using Zen Coding
- using the debugger (along with XDebug)
- snipMate
- using omni completion
- supertab
- and a few more various, useful commands...
voice your opinion now!
vim ide development opinion configuration plugin command
ServerGrove.com: Creating console commands with Symfony2
by Chris Cornutt October 15, 2010 @ 08:53:19
On the ServerGrove.com blog today there's this new post showing you how to create console commands with your Symfony2 codebase in addition to the normal websites you might have generated.
Symfony 2 is mainly used to create web application, however, sometimes you need to extend your app and need a command line tool to help perform tasks around the application. With symfony 1.4.x these were called tasks and it was possible to create a skeleton by using the symfony generate:task task.
While there's not a tool for it, Symfony2 does offer something called "Commands" as a sort of replacement. A basic skeleton of one is included with the framework, there's just no auto-generation tool for them (yet). The basic one, TestCommand.php, shows you how to set up a command's name, arguments and some parameter mapping. The post includes this code example and how it looks when called from the command line.
voice your opinion now!
console command symfony2 taks commandtest tutorial
Solar Blog: Solar CLI - Make-Model
by Chris Cornutt March 11, 2009 @ 11:12:27
The Solar blog has been updated this a new post continuing on the look at the Solar CLI (started here) and its "make-model" command.
This entry is a continuation of the Solar CLI series--a series that aims to detail Solar CLI commands, available options, parameters, and usage examples. In this entry we take a look at make-model, a command that can generate models based on a SQL table.
The post goes through the available options and parameters that you can give the command to make things easier and includes an example of running the "make-model" on a table in a MySQL database (with the code to add to your Solar configuration file to match).
voice your opinion now!
solar framework command line makemodel model mysql tutorial
|
Community Events
Don't see your event here? Let us know!
|