jeudi 20 juillet 2017

Discussion: Which design patterns would you use for this solution?

I would like to design software that has the following solution:

  • Products have features.
  • Each products has rules for features:
    • Product must have features a,b and d. _ Product must have at least x of list of features f,g and m _ Each feature of product has a weight.
  • At runtime I'd like to create products using, from external input (file/user input) and add features to the product with rules.
  • I'd like ask each product, given the features it's been fed, what score it has and what's missing.

Let me illustrate the last point:
Let's say product A has rules regarding must have features a and b, must have at least 2 of c, d, e and f and could also have (but not must) features g, h ,i and j.
I've also assigned the following weights a,b each equal 5, c, d, e and f each equal 10 and g, h ,i and j each equal 2.5. (all in all 60 points)
Case 1:
Product a of type A has features a, c, d, h, j. I'd like the following report:
Is not A because missing b. Score = 0.5 ( (5 + 10 + 10 + 2.5 + 2.5) / 60 )
Can also receive b, e, f, g, i

Case 2:
Product b of type A has features a, b, c, e, h, j. I'd like the following report:
Is A. Score = 0.5833 ( (5 + 5 + 10 + 10 + 2.5 + 2.5) / 60 )
Can also receive d, f, g, i

Here's what I've come up so far:

  • The Products and Features should be created by a factory so they can be generated at runtime and follow the same interface.

  • Reports should be generated using the strategy pattern.

What would you recommend?
Thanks!

Aucun commentaire:

Enregistrer un commentaire