GitBrincie212 / Apel-Mod

Apel is a library that brings particle animations to the table with flexible behaviour and a clean developer interface. It promises also lots of predefined shapes & paths to help the developer on their particle scene
Other
2 stars 1 forks source link

Animator construction should use builders, too #36

Closed DarthSharkie closed 1 month ago

DarthSharkie commented 2 months ago

While animators aren't as parameter-heavy as particle objects, they can take several parameters when constructing. Therefore, like objects, they should adopt the Builder Pattern and deprecate their public constructors.

One reason for this is to allow defining rotation, offset, or both when building an animator. Right now, the telescoping constructor pattern makes this difficult because both rotation and offset are modeled as Vector3f objects, so they're indistinguishable in constructor function signatures. A builder pattern will fix this by naming each parameter as its provided, such as .rotation(rValue).offset(oValue).build(). This should also help with animators that take lists or vararg arrays of parameters, since builders can accumulate multiple values for the same field.

Animators also have several properties, which makes constructor methods difficult to read. IDEs can help by choosing to show parameter names inline, but that doesn't help on GitHub or in a command line environment.

Builders that use super classes can be difficult to get right, since builder methods often declare a return type based on the class in which they reside. This may complicate the approach a little, but should be manageable.

DarthSharkie commented 1 month ago

This is ready, but pending #49.

DarthSharkie commented 1 month ago

Fixed in #49