Rick Harris sure is on a roll. Not only did he discover the Swiss Army Knife of interfaces, but he has come across a rather interesting way of implementing ... or nonimplementing ... an interface ...

We have a standard class library that includes an interface for a shipment and includes a getter and setter for a Bill Of Lading Number:

public interface Shipment {
   //ED: Snip
   public String getBillOfLadingNumber();
   public void setBillOfLadingNumber(String billOfLadingNumber);

While trying to put in an enhancement to an existing application, my co-worker found the class that implements Shipment and called getBillOfLadingNumber() but always got back null even though we knew it had been set in the constructor. Looking at the code, here is what we found:

public class ShipmentInfoSomething implements Shipment {
   //ED: Snip
   private String billOfLadingNumber;
   public String getBillOfLadingNumber() {
      return null;
   public void setBillOfLadingNumber(String billOfLadingNumber) {}

   public String getBOLNumber() {
      return billOfLadingNumber;
   public void setBOLNumber(String billOfLadingNumber) {
      this.billOfLadingNumber = billOfLadingNumber;

So they blew off the methods they had to implement from the interface and made two new ones that did the same thing. And if they really needed both for some reason they could have at least had one call the other so they both worked.

And in other news, you can now express your coding angst with mugs and tee-shirts from CafePress in the Daily WTF Shop. And please let me know if you have any other ideas for slogans.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!