The question I am about to ask is somehow general and may apply to all OOP languages but I'm coding in C#.
How we decide to make a property read-only? In my current program I have made all the properties read-only for all the classes and pass the values via constructor when I initialize them. So all of my classes look like this:
public class Point
{
private double _x;
private double _y;
public double X
{
get { return _x; }
}
public double Y
{
get { return _y; }
}
public Point(double x, double y)
{
_x = x;
_y = y;
}
}
But now I doubt if this is a good idea!? Because now some of the constructors in my classes are getting big and ugly with too many arguments! I'm a bit lost now! What are some guidelines to decide what properties are allowed to be set later and do not need to be passed via constructor!?