Friday, July 8, 2011

Never use the company’s name in your naming convention


I have made a non-negotiable commitment to myself - never again will I put a company’s name (let’s say it’s company XYZ) in any of the items below:
  • java package name (com.xyz....)
  • class or script name (XYZStoredProcedure.java)
  • database table name (XYZ_DOCUMENTS)
  • host name (prod1.xyz-internal.com)
The reason is very simple - things change as the companies or their divisions get sold/acquired/merged into other companies, and nothing looks funnier than explaining to a new team member ‘well, all our packages start with ‘com.xyz’ for historical reasons because XYZ got sold to our new company ABC and it would take too much effort to refactor and then re-test everything’.

What naming convention should you use? Use something generic like ‘App’ (com.app... ,  AppStoredProcedure etc.) and/or something neutral not related to a specific project like ‘Carbon’ or ‘Star’ (so you can have com.app.carbon... or com.carbon...).

Do not worry about java package clash.
In my entire professional experience I am yet to find a third-party library which used the same naming in their package name as I use in mine - most of the open source projects are well-named to prevent package clashes with your code.

So when you start from scratch at your new company do yourself a favor and don’t use company name anywhere no matter how confident you are that ‘this time it will be permanent’. You will thank yourself for that decision in a couple of years.

No comments:

Post a Comment