开发者

Many different input, single type output design pattern

开发者 https://www.devze.com 2023-03-18 11:34 出处:网络
Does such design pattern exists? It is similar but opposite to a factory pattern. The factory accepts a single input (e.g. type A) and creates a variant output (e.g. type X or Y 开发者_如何学运维or Z)

Does such design pattern exists? It is similar but opposite to a factory pattern. The factory accepts a single input (e.g. type A) and creates a variant output (e.g. type X or Y 开发者_如何学运维or Z), depending on the input.

The pattern I'm thinking accepts various different types of input (e.g. type X or Y or Z) but produces only a single type of output (e.g. type A). What pattern is this, if it exists?


That's not a pattern per se, but rather it would require implementing the Adapter pattern as appropriate.


If you are looking for constructing an object from different inputs (objects), the closest I think is Builder pattern. But the intention of builder is to separate construction logic, check http://en.wikipedia.org/wiki/Builder_pattern , if this is what you are looking for .

0

精彩评论

暂无评论...
验证码 换一张
取 消