How to avoid using the same identifier for Class Names and Property Names?

Posted by Wololo on Stack Overflow See other posts from Stack Overflow or by Wololo
Published on 2010-03-30T05:02:54Z Indexed on 2010/03/30 5:13 UTC
Read the original article Hit count: 250

Here are a few example of classes and properties sharing the same identifier:

public Coordinates Coordinates { get; set; }
public Country Country { get; set; }
public Article Article { get; set; }
public Color Color { get; set; }
public Address Address { get; set; }

This problem occurs more frequently when using POCO with the Entity Framework as the Entity Framework uses the Property Name for the Relationships.

So what to do? Use non-standard class names?

public ClsCoordinates Coordinates { get; set; }
public ClsCountry Country { get; set; }
public ClsArticle Article { get; set; }
public ClsColor Color { get; set; }
public ClsAddress Address { get; set; }
public ClsCategory Category { get; set; }

Yuk

Or use more descriptive Property Names?

public Coordinates GeographicCoordinates { get; set; }
public Country GeographicCountry { get; set; }
public Article WebArticle { get; set; }
public Color BackgroundColor { get; set; }
public Address HomeAddress { get; set; }
public Category ProductCategory { get; set; }

Less than ideal, but can live with it I suppose.

Or JUST LIVE WITH IT?

What are you best practices?

© Stack Overflow or respective owner

Related posts about c#

Related posts about properties