Refactoring: Push down method

Previously we mentioned the pull up method we can use during refactoring our code. The push down method is the exact opposite. Let's start with some code:

abstract class animal {
  function bark(){
    // bark here
  }
}
class dog extends animal{}
class cat extends animal{}

$dog = new dog();
$dog->bark();

Maybe one day our cat had a bark about it, or maybe we've coded an if statement to do something different like return false if it's a cat. 

abstract class animal {}
class dog extends animal {
  function bark(){
    // bark here
  }
}
class cat extends animal {}

$dog = new dog();
$dog->bark();

Comments

Popular posts from this blog

Navigating the Jungle of Web Traffic: A Technical Team Lead's Guide to "I'm a Celebrity, Get Me Out of Here"

TCP Handshake over IPv6

The Vital Importance of Secure Wi-Fi Networks