News Feed
Sections




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

DevShed:
PHP Object Oriented Programming using LSP
July 14, 2011 @ 08:57:17

In another part of their series looking at the SOLID principles of software development, DevShed focuses again on using LSP (the Liskov Substitution Principle) to help you organize your application (part one is here).

Even though its formal definition is somewhat hard to grasp, in practical terms it states that methods defined in a base class (or interface) and their derivatives must have the same signature, preconditions should be weakened in the formers, and post-conditions should be strengthened. In addition, if methods in subtypes throw exceptions, they should be of the same type as the ones thrown by the parent abstraction.

You'll need to read the previous tutorial for things to make sense here. They take off running from there, though and get straight into refactoring the previous example to correct a violation of LSP. In the end you'll have a layout/view system that correctly follows the principles and is pretty simple to use too.

0 comments voice your opinion now!
solid software development liskov substitution principle tutorial


blog comments powered by Disqus

Similar Posts

PHPRiot.com: Reducing a Map Path Using Douglas-Peucker Algorithm

SitePoint PHP Blog: UTF-8 Email in PHP with eZ Components

Fortrabbit.com: Multi Stage Deployment for Website Development

Brandon Savage's Blog: Bug-Free: Your Bug-Fixing Toolkit (Part 1 of N)

Nils Luxton's Blog: Installing PHP 5.4.0alpha1 into Wampserver


Community Events

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


feature introduction framework release library series podcast threedevsandamaybe extension api wordpress interview laravel community development opinion language unittest voicesoftheelephpant laravel5

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