My Widget class has a method called loadWidget. This method needs to shuffle an array to work properly, among other things. In Widget, I could implement a Fisher-Yates shuffle as its own static method named shuffle and then call shuffle in loadWidget. However, this looks unseemly to me for two reasons:
The shuffling algorithm has little to do with
Widgetand putting many unrelated algorithms there makes the class harder to read and understand.In the future, I may want to use the Fisher-Yates shuffle in other classes, but it feels like an anti-pattern to call
Widget.shufflewhenever I want to do that.
So the solution could be to create a class of support methods. I could call SupportMethods.shuffle inside Widget and other classes whenever I want to shuffle an array. Is this a good practice or does it violate design principles?