mercredi 1 novembre 2017

Java Pattern for Scoring/Ranking Albums

I'm building a relatively simple algorithm to score albums based on several criteria -- for example, listen count, audio quality, star reviews, existence of album artwork, etc. I'm trying to decide what the best design pattern for this algorithm would be, and I would love input. Right now, I feel like Builder best addresses the problem.

Here are some more details:

  1. Depending on the service that's using the Scorer, the end user can choose which criteria to include or exclude. For example, one service might want to consider star reviews while a different service might not want to score based on star reviews. Ultimately, it should be up to the user to build their scorer however they want.
  2. The inputs for the criteria range from int to String to boolean and other types.
  3. Scores are calculated on each individual album. Other albums do not affect an album's score.
  4. Some baseline criteria must be included. For example, at the very least, the scorer must use listen count and audio quality. As referenced by the first point, on top of those minimum criteria, users can include other criteria.
  5. The input to the algorithm is an album with its accompanying data: [ALBUM, LISTEN COUNT, AUDIO QUALITY, STAR REVIEWS, etc...]

The Builder pattern seems to apply best here because it would allow users to build their own algorithm while avoiding telescoping. Thoughts? Are there other patterns I should consider including with the Builder?

Aucun commentaire:

Enregistrer un commentaire