PBP: 029 Abbreviations

Abbreviations are hard, and the PBP suggests making them by keeping the start of each word, rather than other habits like chopping out vowels or other ways to shorten thing.  It has an effective reason why in a ftnt.

The conclusion to the suggestion is to use standard abbreviations where they exist, which is fine.  It does decide that some are “silly” when they’re just different, but the point is readability and using what makes sense.

This strikes me as an easy one, and I agree with it.

In fact, I often more than agree with it and say “Stop repeating that information”.  Don’t include your class name in every method.  Don’t include the table name in every column name.

I had a SQL class in college where they insisted the table name be the prefix for every column name.  An “artists” table would have “artists_name” and “artists_id” column.  Queries would then select them in as an identifier, and have to fully qualify the table and column, putting the table names in over and over for literally no value.  The habit got even sillier when you pointed the ORM at it and wound up with an ‘artists’ object with half a dozen methods, all of which started with ‘artists_’.

If you don’t need it, you can probably not put it in.  Don’t duplicate things you don’t need.  This is Perl; you’re working in a package.  You don’t have to worry that your function will hit another name and overwrite it.  Use common names, and let the packages sort it out, especially for object methods.


One Response to “PBP: 029 Abbreviations”

  1. Flimm says:

    I used to agree until I started using exuberant ctags. Now I want every subroutine name to be unique across the code-base, and an easy way to ensure that is often to add a package prefix.

Leave a Reply