Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Naming convention to use when converting from database to java variables

I'm currently working on a project where I'm converting database info to java objects, and I was curious has to how I should represent/name the objects and variables on the java side.

For example, if I'm converting a table named Dog containing info about dogs such as: Column: BREED_C, NAME_C, OWNER_C, DOGID_D, HAS_RABIES_I and so on into a java object called Dog with corresponding variables, should I follow a java naming convention such as BreedC or use Breed_C or even BREED_C so there's as little discrepancy between the two systems?

like image 622
JWiley Avatar asked Feb 21 '23 13:02

JWiley


1 Answers

If working in Java, use Java naming conventions.

It sounds like your code should be responsible for abstracting the database layer away from the rest of the application anyway so there is no reason to expose the database representation by naming the Java variables with the exact same name as the database columns.

like image 76
digitaljoel Avatar answered Feb 24 '23 04:02

digitaljoel