If you a have Person Property on Address defined like
public class Address
{
public int AdressId {get; set;}
public Person AddressesPerson {get;set;}
public string FullAddress {get; set;}
}
What is the proper conventions, if any, for naming a property of another type?
Name the property according to its semantic meaning. Frankly it's quite odd to have a Person property on an address - it would normally be the other way round. What's the meaning of the person here? What's the association between the address and the person? You might have Owner
or Resident
, for example - but in other cases that wouldn't be appropriate.
I don't think there's a hard and fast rule, but generally I like to stick to the following guidelines as much as possible:
Owner
might be an appropriate property name, since a Person
owns a particular Address
. 我将从两种类型之间的关系来命名属性,例如居民,所有者等。
Pick one and stick with it.
In your specific case, I wonder why a person is subordinate to an Address, instead of the other way around, but basically just pick the one you want to use and keep using it. As long as it's not something completely unreadable or against some kind of Team coding guidelines, you're probably good.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.