Interfaces and Implementations

Consider a Java interface and class: Dog and DefaultDog. Which of these two conventions is best?

Option 1 : Dog

Name the interface Dog and call the implementation something like DefaultDog or DogImpl.

Option 2 : IDog

Name the interface IDog and call the implementation Dog, DefaultDog, or whatever else you can come up with.

The Answer

I prefer option 1 for these reasons:

  • A vast majority of your code will utilize the interface, rather than the implementation. Thus, it’s best to keep the interface name clean, and reserve the weird names for the implementation classes, which you hardly ever see.
  • Prefixing names with “I” feels like Hungarian notation. The name redundantly specifies what the interface keyword already specifies. Should we also adopt notations for things that are static, final, abstract, etc? I think not.
  • Many interfaces will have multiple implementations. Thus, each implementation will need a different name. I see no need to also put some name discriminator on the interface.

Regarding names like “Impl” and “Default”, I prefer to avoid those when possible. For example, ArrayList and LinkedList are far better names than DefaultList or ListImpl.

U.S. Music Royalty Fee

I haven’t studied my XM Satellite Radio bill for a few months. Starting a few months ago, they added a “U.S. Music Royalty Fee” to my bill, adding $1.98 per month.

They explain it here:

Music royalty rights were established by Congress and are the product of the Copyright Act. Unlike terrestrial radio, both SIRIUS and XM are required to pay copyright music royalties to recording artists, musicians and recording companies who hold copyrights in sound recordings (the actual recording of a work). These royalties have risen dramatically as a result of a decision of the Copyright Royalty Board.

So terrestrial radio gets to skip the fee. I’m guessing they have more lobbyists and political influence. This reminds me of additional state taxes levied on satellite TV providers.

No More Word

A Texas Judge just decided Microsoft cannot sell Word in the US because it saves data as XML. They are expected to pay $200 million dollars.

That just happened.

  1. Every successful software company will eventually be sued for infringing some patent.
  2. Thus, every successful product “violates a patent”, i.e. builds on ideas from some earlier work.
  3. Since every software product builds on ideas from previous generations (or as lawyers say, violates a patent), no software is patentable.

I believe we should eliminate all software patents. Judges, lawyers, and juries lack the technical expertise to understand why patents like this are so silly.

Update

In addition to being fined $200 million dollars for allegedly violating someone else’s word processing XML patent, Microsoft was recently granted patent 7571169 for…saving Word docs as XML.