MatthewRueben / sock-pairing

Try several sock pairing algorithms as an exercise in writing beautiful Java.
MIT License
0 stars 0 forks source link

Reconsider how algorithms are represented and passed #8

Closed MatthewRueben closed 2 months ago

MatthewRueben commented 2 months ago

Initial thoughts:

I should consider just switching each algorithm implementation to a class that gets instantiated and implements an interface, as it is straightforward for the algorithm's parameters (e.g., batch size) to just be instance variables, and this is going with the grain of what's easy to do in Java. Alternatively, I could look into the idea of calling a static method that somehow takes different numbers of parameters for different algorithms, as a method with parameters feels more fitting than an object with instance variables.

MatthewRueben commented 2 months ago

I'm choosing the former option -- i.e., the algorithm is implemented in a class that implements an interface. E.g., class AsYouGoPairer implements PairingAlgorithm

MatthewRueben commented 2 months ago

New strategy implemented in 061a215611596a71d2afc6a5e6053946c40c351f.