Search code examples
.netoopnaming-conventionsclass-design

is placing Entity in the name of a Domain Class a good practice?


currently i am discussing if placing entity at the end of each entity is a good practice for example

public class CustomerEntity:BaseEntity{}

instead of

public class Customer:BaseEntity{}

in my career i had seen both, but how do you do it nowadays?


Solution

  • There are two conflicting bits of advice here, in my opinion. One is to use the simplest name possible, the other is to use a naming convention to make the purpose of your objects clearer when they are being used.

    Personally, if there is not likely to be any confusion as to what a Customer is, I would leave off the Entity part. If you find yourself in a situation where you could have multiple objects named Entity, then I would leave the one that is likely to be used most named Customer, and create some compound noun for the other (like CustomerOrder, CustomerRequest, etc)