Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net SDK problem, which way to go?

Tags:

We're writing an SDK for a CAD program and have run into a slight disagreement regarding a specific type of function (not just disagreement between different people, also disagreement between my two brain-halves).

Imagine there's a lot of classes for specific curve types (ellipse, circle, arc, line, bezier etc.). All of these classes can be represented by a Nurbs curve. So should we put the Circle->Nurbs function on Circle:

public NurbsCurve Circle.ToNurbsCurve()
{
  // Return a circular NurbsCurve or null if the Circle is invalid.
}

or should it be a static on NurbsCurve:

public static NurbsCurve NurbsCurve.CreateFromCircle(Circle)
{
  // Return a circular NurbsCurve or null if the Circle is invalid.
}
like image 930
David Rutten Avatar asked Mar 09 '10 23:03

David Rutten


1 Answers

I think I'd go for the first (e.g. on the shape classes, maybe even with a common base class or interface like IConvertibleToNurbsCurve), because this makes it easier if you add other shapes later which are also convertible to a NurbsCurve.

The NurbsCurve seems to be less specialized and therefore should not "know" about the more specialized types IMHO.

like image 50
Lucero Avatar answered Sep 28 '22 19:09

Lucero