Search code examples
c#oopobjectnaming

Arbitrary Naming Convention (Business Objects)


Ok, do you do Business.Name or Business.BusinessName SubCategory.ID or SubCategory.SubCategoryID

What about in your database?

Why?

I'm torn with both. Would love there to be a "right answer"


Solution

  • The main drawback of using ID, Name etc is that you have to qualify them with the table name if you are writing an SQL join which overlaps two tables.

    Despite that, I find it far more concise and readable to just use ID and Name - your code and tables will 'flow' much more easily past the eyes. Easier to type and less redundant. And typing SELECT Business.Name FROM ... in an SQL query is not really more troublesome than typing SELECT BusinessName FROM ...

    In general, if I find myself repeating semantic information it alerts me to look for ways to eliminate it or at least recognise why it repeats. This could be on the small scale (attribute names) or the large scale (behaviour patterns or common class structures).