12 ms·
I agree that setter properties are often a code smell, but getter properties are nice for calculated fields. As a very simple example, consider the following (C
by clusmore 10y ago
I agree that setter properties are often a code smell, but getter properties are nice for calculated fields. As a very simple example, consider the following (C#):
class Circle
{
public Circle(int radius) { Radius = radius; }
public int Radius { get; }
public int Diameter => Radius * 2;
}
- lacampbell 10y agoDiameter is a nice example of a getter property. However you could change radius to simply public int Radius;
- wtetzner 10y agoI think you mean public final int radius;