简体   繁体   English

哪种设计模式更适合这种情况

[英]What design pattern fits this case better

I am to produce a 2D image from a 3D model and do some calculation on the image and produce some results from that. 我要从3D模型生成2D图像,并对图像进行一些计算,并从中得出一些结果。 Results will be attached at the top of that 2D image as its header. 结果将附加在该2D图像的顶部作为其标题。

  • There are three different types of image which could be produced from a specific scene based on a parameter(DiagramType). 根据参数(DiagramType),可以从特定场景中生成三种不同类型的图像。
  • Also an image can be created via two different ways: Ray tracing or through GPU. 还可以通过两种不同的方式创建图像:光线跟踪或通过GPU。 So the method 'CreateImage' which is responsible to produce the image could have two different signatures (different number of inputs). 因此,负责生成图像的方法“ CreateImage”可能具有两个不同的签名(不同数量的输入)。
  • There are some methods which are common between these different types of diagram or rendering methods. 这些不同类型的图或渲染方法之间共有一些方法。

What design pattern dose fit this case better? 哪种设计模式更适合这种情况?

Would it be better to use abstract class (since there are some common methods which could be inherited) regarding those three diagram types or an Interface? 关于这三种图类型或一个接口,使用抽象类(因为可以继承一些通用方法)会更好吗?

I am mostly concerned with this 'CreateImage' method which can have different signature regarding the method that is used, Such that each digram type would have one 'CreateImage' method regardless of diagram type and rendering method.(Im not sure this would be possible at all). 我最关心的是这个'CreateImage'方法,该方法对于所使用的方法可能具有不同的签名,因此每个图类型都将具有一个'CreateImage'方法,而与图的类型和呈现方法无关。(不确定这是否可能完全没有)。

"Three different xxx vs two different yyy" which depend on each other sounds immediately like the Bridge Pattern to me. 彼此依赖的“三个不同的xxx与两个不同的yyy”听起来像是我的桥接模式。

In other words, you have a hierarchy of xxx, a hierarchy of yyy and xxx accepts injected yyy. 换句话说,您的层次结构为xxx,层次结构为yyy,并且xxx接受注入的yyy。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM