During a recent project I've been working on, I've had to use a lot of functions that kind of look like this:static bool getGPS(double plane_latitude, double plane_longitude, double plane_altitude,                       double plane_roll, double plane_pitch, double plane_heading,                       double gimbal_roll, double gimbal_pitch, double gimbal_yaw,                        int target_x, int target_y, double zoom,                       int image_width_pixels, int image_height_pixels,                       double & Target_Latitude, double & Target_Longitude, double & Target_Height);So I want to refactor it to look something like this:static GPSCoordinate getGPS(GPSCoordinate plane, Angle3D planeAngle, Angle3D gimbalAngle,                            PixelCoordinate target, ZoomLevel zoom, PixelSize imageSize)This appears to me to be significantly more readable and safe than the first method.  But does it make sense to create PixelCoordinate and PixelSize classes? Or would I be better off just using std::pair<int,int> for each. And does it make sense to have a ZoomLevel class, or should I just use a double? My intuition behind using classes for everything is based on these assumptions:If there are classes for everything, it would be impossible to pass a ZoomLevel in where a Weight object was expected, so it would be more difficult to provide the wrong arguments to a functionLikewise, some illegal operations would cause compile errors, such as adding a GPSCoordinate to a ZoomLevel or another GPSCoordinateLegal operations will be easy to represent and typesafe. i.e subtracting two GPSCoordinates would yield a GPSDisplacementHowever, most C++ code I've seen uses a lot of primitive types, and I imagine there must be a good reason for that. Is it a good idea to use objects for anything, or does it have downsides that I am not aware of?
Would it make sense to use objects (instead of primitive types) for everything in C++?
c++;type systems;data types;type safety
Yes, definitely. Functions/methods that take too many arguments is a code smell, and indicates at least one of the following:The function/method is doing too many things at onceThe function/method requires access to that many things because it's asking, not telling or violating some OO design lawThe arguments are actually closely relatedIf the last one is the case (and your example certainly suggests so), it's high time to do some of that fancy-pants abstraction that the cool kids were talking about oh, just some decades ago. In fact, I'd go further than your example and do something like:static GPSCoordinate getGPS(Plane plane, Angle3D gimbalAngle, GPSView view)(I am not familiar with GPS so this is probably not a correct abstraction; for instance, I don't understand what zoom has to do with a function called getGPS.)Please prefer classes like PixelCoordinate over std::pair<T, T>, even if the two have the same data. It adds semantic value, plus a bit of extra type safety (compiler will stop you from passing a ScreenCoordinate to a PixelCoordinate even though both are pairs.