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

PHPMaster.com:
Practical Code Refactoring, Part 3 - Extensibility
Oct 25, 2012 @ 14:22:05

PHPMaster.com has posted the third part in their "Practical Code Refactoring" series - this time with a focus on Extensibility. (Part 1, Part 2).

Extensible code is a piece of code which follows re-usable, logical, well-known patterns, be it standard design patterns, or normal logical flow. Modular code tends to be highly extensible and monolithic code tends to be non-extensible, but monolithic code might be more efficient, so to solve this conundrum some practices allow developing in a modular way and deploying in a monolithic way so we can get the best of both worlds. The major aspects which we are to discuss with regard to extensible code are: logical extensibility (normal logical flow and design patterns), modular design, and decoupling and encapsulation.

He goes through each of the sections - logical extensibility, modular design and decoupling/encapsulation - and for each provides some questions to ask to help you whip your code into shape.

tagged: code refactor extensibility series decoupling encapsulation modular

Link:

PHPMaster.com:
Decoupling Interfaces from Implementation - Using Separated Interfaces
Jun 14, 2012 @ 13:19:56

On PHPMaster.com today there's a new tutorial looking at using separated interfaces in your OOP applications, a design pattern that emphasized decoupled components.

Considering that the concept may sound rather tangled and twisted at first, this shifting of protocols between components lives and breaths under the umbrella of a basic design pattern known as Separated Interface, which at least to some extent, goes hand in hand with the commandments of the Dependency Inversion Principle. Moreover, because of the pattern’s easy-going nature, it’s feasible to implement it in PHP without much fuss.

He shows how to create a basic model (with getters and setters) and extends this into functionality to handle "Post" and "Comment" data types. The key to it all is that the "Comments" model instance is injected into the "Post" model on its creation, making it a self-contained, but still modular, object for handling all elements of a post in one place.

tagged: decoupling tutorial separated interface

Link:


Trending Topics: