DPC15 uncon talk: How cyborg puppies can sniff out code smell

download DPC15 uncon talk: How cyborg puppies can sniff out code smell

If you can't read please download the document

Transcript of DPC15 uncon talk: How cyborg puppies can sniff out code smell

  1. 1. How cyborg puppies can sniff out code smell Niels van Esch @goatcode https://joind.in/14706
  2. 2. OOP 101
  3. 3. class Dog { public function bark() { echo woof; } }
  4. 4. class Chihuahua extends Dog { public function bark() { echo kef-kef; } }
  5. 5. class GermanShepherd extends Dog { public function bark() { echo ACHTUNG!; } }
  6. 6. Abstract class Dog { public function bark() { echo woof; } public function wagTail() { echo woosh!; } }
  7. 7. class Tail { public function wag() { echo woosh; } }
  8. 8. class Dog { private $tail; ... public function wagTail() { if($this->tail === null) { $this->tail = new Tail(); } $this->tail->wag(); } }
  9. 9. Command pattern $command->execute();
  10. 10. Command handler $handler->handle($command);
  11. 11. Command bus $commandBus->handle($command);
  12. 12. More real examples using furniture to check Single responsibility principle Open/closed principle Liskov substitution principle Interface segregation principle Dependency inversion principle
  13. 13. Questions? Niels van Esch [email protected] @goatcode https://joind.in/14706