I'm creating a math library that will deal with points as function inputs (as shown below).
public struct Point { public int X; public int Y; }
public static class MyLib
{
public static float CalculateSomething(Point point1, Point point2)
{ ... }
...
}
My plan is to be able to use it alongside various graphics/gaming libraries and as such that will require transformation from whatever that Point type is from the graphics library to the one provided by my library before it can be used.
Using a Point struct (or class in Java version) as a Parameter Object, which would be object parameter coupling is a clean and nice way to simplify knowing what to pass in but it also requires mapping it to my Point struct/object first before every function call:
var mappedPoint1 = new Point(point1.x, point1.y);
var mappedPoint2 = new Point(point2.x, point2.y);
var result = MyLib.CalculateSomething(mappedPoint1, mappedPoint2);
An alternative could be to use a simple data parameter coupling where only primitive types are passed as parameters:
var result = MyLib.CalculateSomething(point1.x, point1.y, point2.x, point2.y);
I can also see pros/cons to this approach as well since it doesn't require mapping to a data object but does have problems if they mess up the order of primitive types being passed in. Or if more parameters are needed, it would start to become a large parameter list.
What kind of coupling here will be the least taxing on the calling code? While primitive parameters are the simplest to interface with the point abstraction brings clarity and context but also demands more work and mapping code.