Search code examples
javalenskit

Lenskit: FunkSVD


I need to slightly change FunkSVD algorithm. Basically, I just need to replace FunkSVDUpdater, but it turned out that FunkSVDUpdater as well as FunkSVDUpdateRule are final classes, which means I cannot extend them. My solution is to copy FunkSVD classes and make necessary changes.

  • Is there a reason, why FunkSVDUpdater and FunkSVDUpdateRule are final?
  • Is there a better way to change FunkSVD algorithm in Lenskit?

Solution

  • LensKit lead developer here.

    They're final because we generally take a 'final by default' approach (consistent with Effective Java), in turn because it is very difficult to design classes to be extended without things breaking down badly in the face of future updates, especially while maintaining any kind of API guarantees.

    Usually, what we do is to have an interface (or occasionally an abstract class) that the final class implements, and then the interface can be reimplemented. This hasn't been done for the FunkSVD updater and update rule classes; this is mostly an oversight or a haven't-gotten-to-it-yet problem.

    So, at present, the best option is to copy the code. We're certainly open to opening up these extension points; I would recommend opening an issue on GitHub where we can discuss in more detail the ramifications of doing that and track and complete the work.