I am writing an API for creating geometric shapes, and I am having some difficulties naming my methods.
Take a simple case: creating a circle. Most of us may be familiar with the type method graphics.drawEllipse(x, y, w, h). To draw a circle, you need to know the upper left coordinate, as well as the width and height of the circle.
My API is designed so that the developer easily draws shapes using a variety of information, without doing a lot of math, which is trivial for circles, but more complex for other shapes. For example, you should also be able to draw a circle, taking into account its central coordinates and radius, as well as the upper left and lower right coordinates.
So I have a class Circlewith factory, for example:
Circle.createWithCenterAndRadius(cx, cy, r)
Circle.createWithBoundingBox(x1, y1, x2, y2)
Circle.createWithWidthAndHeight(x, y, w, h)
I feel that there might be a “code smell”, but I'm not sure. On the one hand, these factory methods are necessarily descriptive. On the other hand, I can foresee that these method names get out of hand. For example, what can I call the factory triangle method that creates a triangle based on a point, the length of one side, the angle and the length of the other side? Triangle.createWithPointSideAngleAndSide(x, y, side1, angle, side2)? Is it just evil?
If you intend to use this API, will the method names like this be okay? Do you have any tips on how I can make method names more reasonable?