Patrick Schwisow

Month: June, 2012

Response to “On Visibility in OOP”

I just read Matthew Weier O’Phinney’s On Visibility in OOP.  Aside from being an excellent and easy to follow explanation of public / protected / private / final in PHP, MWOP’s experiences dealing with private and final in framework and library classes somewhat echo my own.

In the example he presented, he was unable to extend and improve Doctrine\Common\Annotations\DocParser due to the fact that it has private members and is marked as final. This proved a significant roadblock to interoperability between Zend Framework 2 and Doctrine 2.

In my case, I also encountered a roadblock in Doctrine 2, but for me it was a block to testability. Doctrine\ORM\EntityManager is marked as final, and while I understand the reasoning behind the statement “this should not be extended”, I would propose that in the case of creating tests, this reasoning no longer applies. To allow the flexibility necessary to create effective tests, it is frequently necessary to extend a class in order to create a mock or proxy. If the class in question is final or makes most of its inner workings private, we must resort to overly complex and less realistic methods to create tests for code that touches it.  This in turn decreases the chances that our tests are actually covering the cases we intend them to cover and increases the chances of false positives and false negatives from the test suite. In short, we’re forced to choose between “hacking” someone else’s code to change visibility or creating very brittle tests.


Interview on Voices of the ElePHPant

When I was at php|tek 12 a few weeks ago, I had the pleasure of recording an episode of the Voices of the ElePHPant Podcast with The Cal Evans. The episode published today, so I guess I’m now #internetfamous. In all honesty, I was pretty nervous about it, so I’ll be listening along with everyone else to hear what I said. I know I talked about PHP User Groups, Community, and Conferences.

One thing I intended to do was thank all the wonderful sponsors who helped Lake / Kenosha PHP get off the ground with the generous donations of “swag” for the new members.  I’ll take the time to thank them now:

Thank you all for your generous support of of the community, and thank you also to the other companies who generously provided the next round of giveaways for LKPUG and many other user groups at php|tek this year.