Null Object Design Pattern
- in object-oriented computer programming, a null object is an object with no referenced value or with defined neutral behavior
- was first published in the Pattern Languages of Program Design book series
Code Example
public interface Animal {
void makeSound() ;
}
public class Dog implements Animal {
public void makeSound() {
System.out.println("woof!");
}
}
public class NullAnimal implements Animal {
public void makeSound() {
// silence...
}
}