Consider both equivalent pieces of code:
private List<Configuration> _configurations;
public List<Configuration> Configurations
{
get { return _configurations; }
set { _configurations = value; }
}
and
public List<Configuration> Configurations { get; set; }
To a reader, assuming she is knowledgeable of C#, the second piece code is very quick to read. The first one takes longer and does not add any information. In fact, it adds useless information: I have a property Configurations
, but I also have an equivalent field _configurations
, and the code in the rest of the class may use any of them, so I have to take them both into account. Now imagine your class has fifteen properties like this one, for instance. Using automatic properties you greatly reduce complexity for whoever is reading the code.
Besides, if you consistently use automatic properties, whenever you write a non-automatic one the reader is warned immediately that there is something going on there. This useful information is hidden if you don't use automatic properties.
In summary, consistent use of automatic properties:
- Reduces code length
- Reduces the time needed for reading and understanding a class
- Hides useless information
- Makes useful information easier to find
What's not to like?