PBP: 027 Underscores

The PBP suggests using underscores to separate phrases in a variable name.  Since we can’t use spaces or hyphens, as English (and many other languages, honestly) would have us do, we have to use something else.

The PBP suggests an underscore.  Problem: I dislike underscores.

I used to say “hate” but I’m getting older and giving less of a damn.  It seems like a pretty minor thing to hate when the world is filled with war and child abusers and Wall Street tycoons who crash the entire economy to make more profit for themselves.  So, I don’t hate underscores any more.

The underscore is way off over there on the wrong corner of the keyboard, you have to type a needless shift to get to it, and it adds little actual meaning, at least in my mind.  I used to prefer mixed case, using a capital letter to separate words, what some call CamelCase.

I bending to the general pressure and using them as separators lately.  Not because I think it’s right, but because I think it’s not worth the trouble of fighting over.  In addition, DBIx::Class means a closer tie-in to SQL where mixed case doesn’t always work.  Since I’m forced to underscores there, I wind up using them in the SQL, which translates into methods in DBIx::Class objects.  Having some methods LookLikeThis and others look_like_this is worse than the underscores, so I’m going underscore everywhere.

This puts me in grudging agreement with the PBP, but I still don’t like it.

 

 

One Response to “PBP: 027 Underscores”

  1. Personally I believe in taking the underscores even further, and never using camel case; in Perl that means using that format for package names too, where the distinction with package names is that each word is capitalized rather than being lowercase; e.g. I prefer Foo_Bar for a package and foo_bar for a subroutine or variable, camel case being ugly.

Leave a Reply