简体   繁体   中英

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. Results will be attached at the top of that 2D image as its header.

  • There are three different types of image which could be produced from a specific scene based on a parameter(DiagramType).
  • Also an image can be created via two different ways: Ray tracing or through GPU. So the method 'CreateImage' which is responsible to produce the image could have two different signatures (different number of inputs).
  • 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).

"Three different xxx vs two different yyy" which depend on each other sounds immediately like the Bridge Pattern to me.

In other words, you have a hierarchy of xxx, a hierarchy of yyy and xxx accepts injected yyy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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