News Feed
Sections




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

DZone.com:
Open/Closed Principle on real world code
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).

0 comments voice your opinion now!
open closed principle solid design command phpunit selenium


blog comments powered by Disqus

Similar Posts

ServerGrove.com: Creating console commands with Symfony2

Sebastian Bergmann\'s Blog: PHPUnit Support in PHP IDEs

Sebastian Bergmann\'s Blog: PHPUnit Talk at PHP Usergroup Dortmund

Robert Peake\'s Blog: Design Patterns Part II Is Out

Sebastian Bergamnn's Blog: SeleniumTestCase Improvements in PHPUnit 3.2


Community Events





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


language community framework interview threedevsandamaybe list developer refactor api introduction testing laravel release series podcast install opinion symfony2 code unittest

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