I was trained in SQL years ago and was encouraged to use lower-case
letters with words separated for emphasis using the underscore
character, for example:
customer_num, employee_id, invoice_line, transaction_code
I've stuck with this approach ever since, but now that I make use of
oo programming the general standard is to name oo instance variables
without underscores and capitalising all words except the first for
emphasis, such as:
customerNum, employeeId, invoiceLine, transactionCode
However, bridging the gap between relational databases and oo
programming means that when binding table column names to object
variable names, I really need to pick one or the other (you may
disagree but that's my aim).
So, when it comes to naming columns, what are most of you using?
I don't see why column names have to be the same as property names. In
fact, it can be good to see what kind identifier it is. But if you have
already decided that they must be the same, just pick the most legible one.
Best regards,
--
Willem Bogaerts
Application smith
Kratz B.V.
http://www.kratz.nl/
>I don't see why column names have to be the same as property names. In
>fact, it can be good to see what kind identifier it is. But if you have
>already decided that they must be the same, just pick the most legible one.
You're right, of course. I've just partially implemented a Facade
pattern which takes care of the translation via a ColumnMap for the
DatabaseBroker.
That's how I name my columns.
I don't know that I can justify it[1], but I generally use the practice
you're trying to get away from, namely lower-case with underscore-separated
words for MySQL, but letter-case-separated words (so-called 'camelCase') for
pretty much all 'proper' programming languages.
It hasn't tripped me up yet (in fact, as William suggested, I think it's
handy to make an obvious distinction), but that may be just because I'm not
trying hard enough... :-)
A.
[1] In fact, I'm fairly sure I can't! ;-)