Skip to main content
2 of 2
added 266 characters in body
Doc Brown
  • 214k
  • 34
  • 394
  • 603

it just feels wrong to have a class that does nothing but validate and store values

For me, it feels perfectly fine - as long as you can come up with a meaningful name for the class, one which lets you think of the group of parameters "as a whole", without always having to remember what's inside. I don't know your domain, but Angles sounds pretty meaningless to me - but maybe it is just so inexpressive for the sake of this example, not in the real code. Same holds for convert - give the function a name which expresses clearly what kind of conversion it does - from what input to what output. And the comment behind _Angle0 indicates the method should have a name like _validateAngle0, for example.

Additionally, consider to implement the conversion functions as class methods of Angle. It is probably not possible to implement them as different Angle constructors, since they are cannot be distinguished just by their signature, so class methods should be the canonical choice here.

Note that if you cannot come up with a better name for this group of four angles, that might be a sign that you chose the wrong abstraction.

Doc Brown
  • 214k
  • 34
  • 394
  • 603