Maybe it's because
- I've had to write the same DBI connection code over and over
- I've had to have a $dbh available in a bazillion different places
- I've needed config files for other reasons
- I'm just really paranoid about usernames/passwords in code
but I find that making decisions in code about which database to connect to based on an environment variable is obfuscated by its very nature. The ternary operator is not obfu. I personally don't use it a lot (kinda like I don't use
select alot), because I abstract decisions away to the entity that needs to make the decision. (I'm a refactoring-nazi, actually.)
I'm going to take issue with your last paragraph. Any developer worth their salt should have a number of modules in use that allow for reuse. For example, I have a set of tools that would allow me to do almost any one-off task without writing much code for database connections, configuration, and the like. And, it's almost quicker to write it factored out than it is to write it as one big blob. Why? Because it's easier to verify that your code which may only have one chance to be executed will do it right. Because you're never noticed when you succeed, but you're in the spotlight if you fail. Developers will always have time to develop correctly, if they plan as if they will need to do so in the next hour.
------
We are the carpenters and bricklayers of the Information Age.
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.