Properties are very similar to methods; you end up with a getter/setter method under the hood, as you have already seen. However, methods and properties have different usage patterns. You should view properties as fields on steroids. While they look like fields, the syntax for a property looks like we are dealing with a field; properties provide the flexibility of methods.
A class method represents an action, while a property represents data. Properties should be used like a field and not like an action or behavior. When you want to design your type and define one or more properties, use the following guidelines to decide whether it is suitable to do so:
- Avoid having complex code in the getter code body. A caller expects a fast return. Definitely do not connect to a database or make a rest call from the property's getter code base.
- Getting a property...