Reputation: 910
I have a question related to "Private Data Class Design Pattern".
Is it possible to have both get and set accessor to the data class in a "Private Data Class Design Pattern". like the one below
public class CircleData {
public double Radius { get; set; }
public Color Color { get; set; }
public Point Point { get; set; }
}
public class Circle {
public void Draw(CircleData circleData)
{
// Perform the draw operation
}
}
Here I have tried to eliminate the coupling between methods the attributes (properties) Is this "Private Data" design pattern?
Upvotes: 1
Views: 951
Reputation: 21969
As I mentioned in chat, I'm not sure that what you're trying to do with this Private Class Data pattern is beneficial to you at all.
Whilst you're not explicitly implementing the private backing store for your properties, it is implied so technically you do have public properties that access private data, but I believe the point of the whole pattern is to hide internal information on the class.
A better example might be the following fields/property:
private int _x = 5;
private int _y = 15;
public Point Point {
get {
return new Point(_x, _y);
}
set {
_x = value.X;
_y = value.Y;
}
}
But again, that would only be beneficial to you if you used the x/y values independently of the Point
.
Upvotes: 1