I have a class that only holds data, specifically Collections of data, it is called *BezierSplineData:
class BezierSplineData
{
public List<BezierSplineControlPoint> ControlPoints; // ControlPoints that can change the shape of the spline.
public List<BezierSplinePoint> Points; // Actual points in the 3D world that represent the spline.
}
BezierSplineControlPoint has only 3 fields:
- Position
- FirstTangentPosition
- SecondTangentPosition
BezierSplinePoint only 1:
- Position
Another class called BezierSplineCalculator, it is used to calculate 3D points for a set of BezierControlPoint's.
class BezierSplineCalculator
{
public BezierSplineData Data;
private void Recalculate()
{
// Code that will recalculate the Data.Points based on the Data.ControlPoints;
// Essentially generates the actual spline.
}
}
Now the BezierSplineCalculator class can have methods such as, AddControlPoint(BezierSplineControlPoint controlPoint), and other methods like RemoveControlPoint, InsertControlPoint and probably more, this would cause a recalculation of the spline.
My question is, it doesn't look right that I have a separate class just for that as I would need to refer to that Data quite often, let's say I need to render that BezierSpline, I would create a BezierSplineRenderer class and access the Data field from the BezierSplineCalculator class.
Is this a code smell, should I keep the data and calculator in one class?
Aucun commentaire:
Enregistrer un commentaire