 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Michael Kimsal's Blog: magic __get and __set style?
by Chris Cornutt December 21, 2010 @ 09:36:05
In this recent post to his blog Michael Kimsal asked about the usefulness of the __get and __set magic methods and the sort of code he usually sees along with it.
For a long time I've held that __get and __set in PHP were not all that hot - mostly because it's solely error handling. There's no way to deal invoke __get or __set behaviour for properties that are defined on a class. [...] For those who insist on using __get/__set, I *typically* see this [messyy] sort of style code. The effect is to cram a bunch of unrelated code in to the __get/__set overloading methods.
He suggests an alternative to the "cram it all in __get" approach - callbacks to other methods in the class to handle the different variable possibilities. In the comments there's other suggestions on how to get the same job done differently - mapping property values with __call, valid uses for getters/setters and a pointer to an internals discussion RFC about this same thing.
voice your opinion now!
getter setter oop class behavior opinion
ServerGrove Blog: Interesting symfony plugins sfBehatPlugin
by Chris Cornutt September 21, 2010 @ 08:09:57
On the ServerGrove blog there's a new post spotlighting one of the Symfony plugins they think is interesting - the sfBehatPlugin, an interface into the Behat system for behavior-driven development.
Quality assurance (QA) is one of the most difficult things to implement around software development. Most of time it is left for the final phase of development and very often overlooked entirely. As many experienced web development teams already know, QA needs to be part of the development process from the get-go. [...] Behavior development/testing is just one aspect of quality assurance.
They briefly touch on the installation of the plugin (Symfony plugins are usually pretty easy to get set up) and link to the project's homepage for more references on some of the basics of using it to act as a browser, parse the response and use forms on a page.
voice your opinion now!
symfony plugin behavior driven development behat interface
PHP in Action Blog: One behavior != one assertion
by Chris Cornutt February 24, 2009 @ 11:13:17
On the PHP in Action blog, despite some agreement with Padraic Brady on his one behavior, one assertion method for writing unit tests, Dagfinn Reiersol still has his reservations.
Pádraic maintains that one assertion per test is a rule that should always be followed unless there is a specific good reason to break it. I prefer it as a guideline, as does Robert C. Martin in the book Clean Code. The reference is not intended as an appeal to authority to "prove" that I'm right. I'm just making the point that I think this reflects the current state of the art, which is not necessarily perfect, of course.
Dagfinn talks about behavior-driven development and illustrates how a two assertions could be combined into one but that the end result "isn't very pretty" - and that's just testing two proterties of a single object. Imagine what would happen if things got more complex.
voice your opinion now!
unittest behavior assertion reservation opinion padraicbrady
Blog.szajbe.pl: Not so obvious behavior of $uses in CakePHP
by Chris Cornutt July 09, 2008 @ 12:02:41
In this new post to the blog.szajbe.pl site a dilemma is presented - CakePHP models are not working they way one would think they should.
In CakePHP you declare what models you're going to use in a controller by defining $uses variable. You can also define it in AppController to have a certain set of models available in every controller. However be careful when doing it because you may put yourself in an unexpected situation as I did recently.
As soon as he made his script include a 'User' model in every quest, his logins stopped working. His script errored with a "Database table sessions for model Session was not found" message and refused to work. Digging deeper, he found that CakePHP merges an AppController's $uses value with the SessionControler's values. One overrides the other and your 'User' gets lost in the shuffle.
Do you have a rational explanation for such behavior? I have none. It's very unintuitive for me.
voice your opinion now!
cakephp model behavior user login appcontroller sessioncontroller merge uses
Padraic Brady's Blog: PHPMutagen Mutation Testing for PHP5
by Chris Cornutt December 05, 2007 @ 09:32:00
In another behavior-driven development related post on his blog, Padraic Brady talks about mutation testing and a library he's put together to support it in PHP - PHPMutagen.
As I said in my previous entry I was thinking about how to write a Mutation Testing engine. The "braindump" was to use PHP's built in Tokenizer to break down a class file into digestible pieces which could be mutated, and then reconstructed into a mutated file. Once you allow for a working copy of the original source (let's not mutate the original!) it turned out to be a reasonable approach.
He's not releasing it just yet ("don't get too excited until I find some time to scan through it again") but he does share some sample output from his test run - one instance where all is well and the other where one mutant "escapes" and causes an exception.
voice your opinion now!
mutation testing php5 phpmutagen behavior development mutation testing php5 phpmutagen behavior development
|
Community Events
Don't see your event here? Let us know!
|