讨论:您将为该解决方案使用哪些设计模式? [英] Discussion: Which design patterns would you use for this solution?

查看:112
本文介绍了讨论:您将为该解决方案使用哪些设计模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设计具有以下解决方案的软件:

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 features f,g and m _ Each feature of product has a weight.

      让我说明最后一点:
      假设 product A具有有关必须具有特征a and b,必须具有至少2个c, d, e and f以及可能具有(但不是必须)特征g, h ,i and j的规则. 我还分配了以下权重a,b each equal 5c, d, e and f each equal 10g, 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 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

      情况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:
      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:

      • ProductsFeatures应该由factory创建,以便它们可以在运行时生成并遵循相同的界面.

      • The Products and Features should be created by a factory 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 the Product class, Feature a is just an instance of the Feature class) to justify patterns. Not even a Factory is needed, IMO. Am I missing something from your question?

      这篇关于讨论:您将为该解决方案使用哪些设计模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆