Posts

Showing posts from May, 2014

Refactoring and Kata

Martin Fowler has a pretty good site on refactoring -  http://www.refactoring.com/ Coding Dojo Katas -  http://codingdojo.org/cgi-bin/index.pl?KataCatalogue

PHP TDD Shopping Cart from scratch.

So, I've finally taken the plunge again and started seriously looking into refreshing my dusty old brain cells about TDD and unit testing. Over the past few weeks I have been re-reading various books, reading articles and watching video-casts by some of the leading names surrounding Testing, TDD, Design patterns and tackling legacy code, and the inspiration has finally got to me that I just need to tackle this head on.  Consuming a wealth of information about greenfield and brownfield systems and how to tackle them. I have also revisited daily coding Kata's, taking 15mins in the morning or evening to tackle a simple Kata to get my brain in "test first" mode. The array of books and information I have consumed has been immense and I'll probably re-read and watch everything again, and get a different perspective on things, although I guess the main way to learn is by doing, which is why I raked through the archives (then ended up password resetting) my github a

Why you should never extend the interface

Hello, there What's wrong with this code sample? <?php     class MyClass {         public function myFunction() {         }     }          class myOtherClass extends MyClass {         public function MyOtherFunction() {         }     }         class Controller {         public function doSomething(MyClass $object) {             $object->MyOtherFunction();         }     } On first blush, it might seem that this is ordinary inheritance, and we're doing everything we should be doing. But there's something very wrong here. The problem here is that we're extending the interface. Extending the interface itself isn't necessarily bad, but we're making a second mistake: we're then typehinting on the wrong object type. Let's talk about why we want to avoid this practice. The Liskov Substitution Principle I've discussed the Liskov Substitution Principle a few times through this newsletter. But let's go over it again. The Liskov Substitution