I have many math types like Point3, and I am running into the dilemma of implementing operators, instance and static methods for arithmetic.
So say the type is Point3
. Where a, b, c is a Point3
, I sure wanna be able to say:
c = a + b;
But should I also implement:
c = Point3.Add (a, b);
And this:
c = a.Add (b);
To me #3 is useless and less readable than #1. And #2 seems like pointless unless you have an interface for Add, Subtract, Multiply, Divide, etc.
What do you recommend? Is there any problem or drawback with just having the operators (+, -, *, /)? Would this impede the generics arithmetic (I know it doesn't support it directly, but maybe having static methods would be useful in a workaround)?
Would a guidelines for this matter whether it's a class or a struct?
EDIT: Also for #3, I forgot to mention that this is for an immutable type, so returns a new Point3, instead of changing a.