讨论:您将为该解决方案使用哪些设计模式? [英] Discussion: Which design patterns would you use for this solution?
问题描述
我想设计具有以下解决方案的软件:
I would like to design software that has the following solution:
- 产品具有功能.
- 每种产品都有以下功能规则:
- 产品必须具有功能
a,b and d
. _ 产品必须至少具有功能列表f,g and m
中的x _产品的每个功能都有权重.
- 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 featuresf,g and m
_ Each feature of product has a weight.
让我说明最后一点:
假设 productA
具有有关必须具有特征a and b
,必须具有至少2个c, d, e and f
以及可能具有(但不是必须)特征g, h ,i and j
的规则. 我还分配了以下权重a,b each equal 5
,c, d, e and f each equal 10
和g, h ,i and j each equal 2.5
. (共60分)
情况1:
类型为A
的产品a
具有功能a, c, d, h, j
.我想要以下报告:
不是A,因为缺少b
.分数= 0.5((5 + 10 + 10 + 2.5 + 2.5)/60)
也可以接收b, e, f, g, i
Let me illustrate the last point:
Let's say productA
has rules regarding must have featuresa and b
, must have at least 2 ofc, d, e and f
and could also have (but not must) featuresg, h ,i and j
.
I've also assigned the following weightsa,b each equal 5
,c, d, e and f each equal 10
andg, h ,i and j each equal 2.5
. (all in all 60 points)
Case 1:
Producta
of typeA
has featuresa, c, d, h, j
. I'd like the following report:
Is not A because missingb
. Score = 0.5 ( (5 + 10 + 10 + 2.5 + 2.5) / 60 )
Can also receiveb, e, f, g, i
情况2:
类型为A
的产品b
具有功能a, b, c, e, h, j
.我想要以下报告:
是A.得分= 0.5833((5 + 5 + 10 + 10 + 2.5 + 2.5)/60)
也可以接收d, f, g, i
Case 2:
Productb
of typeA
has featuresa, 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 received, f, g, i
这是到目前为止我要提出的内容:
Here's what I've come up so far:
-
Products
和Features
应该由factory
创建,以便它们可以在运行时生成并遵循相同的界面.
The
Products
andFeatures
should be created by afactory
so they can be generated at runtime and follow the same interface.
报告应使用
strategy
模式生成.您会推荐什么?
谢谢!What would you recommend?
Thanks!推荐答案
域模型很有用(我认为我根据您的文字正确理解了此模型):
A domain model is useful (I think I got it right based on your text):
从那里,我看不到设计上的足够变化(例如,产品
A
只是Product
类的实例,功能a
只是Feature
类的实例)来证明模式的合理性. IMO甚至不需要工厂.我在您的问题中遗漏了什么吗?From there, I don't see enough variations in design (e.g., Product
A
is just an instance of theProduct
class, Featurea
is just an instance of theFeature
class) to justify patterns. Not even a Factory is needed, IMO. Am I missing something from your question?这篇关于讨论:您将为该解决方案使用哪些设计模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- Product must have features
- 产品必须具有功能