3 ms·
Depends, but objects aren't just about state. There's dynamic dispatch too. You can have different stateless strategies, and at runtime you might want to be abl
by scarmig 10y ago
Depends, but objects aren't just about state. There's dynamic dispatch too. You can have different stateless strategies, and at runtime you might want to be able to swap one out for another. If that was a requirement, static methods don't work.
- bfung 10y agoLooks like parent post is on the money for the reason this library was done w/o static methods. Note that there are interfaces in the library. https://github.com/tdebatty/java-string-similarity/blob/master/src/main/java/info/debatty/java/stringsimilarity/Levenshtein.java#L12 https://github.com/tdebatty/java-string-similarity/blob/mast... The example code in README.md can probably do this instead: MetricStringDistance msd = new Levenshtein(); System.out.println(msd.distance("My string", "My $tring")); MetricStringDistance msd2 = new MetricLCS(); System.out.println(msd2.distance("ABDEF", "ABDIF"));
- scarmig 10y agoFancy seeing you here! Hope you're enjoying your vacation :)