Imagine a situation where we're using a library that allows you to create Circle
objects, where you can specify the radius and the center of the circle to define it. However, for some reason, it also takes a required flavour
parameter. Now let's say I really need to use Circle
in my own app, but for the purposes of my app I can set the flavour to be Flavours.Cardboard
every single time.
To "solve" this, I create my own Circle
class in a different namespace, which only takes radius
and center
as parameters, but has an implicit converter to the external library's Circle
class which just creates a Circle(this.radius, this.center, Flavours.Cardboard)
object. So everywhere I need the other type of Circle
, I let the automatic conversion take place.
What are the consequences of creating such a class? Are there any better solutions? Would it make any difference if my application was an API built on top of this external library, intended for use by other programmers?
MakeCircle
function?makePlayer
that itself only accepts coords to place the player at, but delegates to a much more complex constructor.