The Decorator Pattern & Extension Methods in c#

前端 未结 5 2035
情歌与酒
情歌与酒 2021-02-04 01:59

Before going to describe my problem first,I would like to define definitions of Decorator and Extension method Decorator

Attach additiona

5条回答
  •  情深已故
    2021-02-04 02:24

    Extension method a Decorator pattern or a Visitor pattern? After reading I would say its more akin to the Visitor.

    Quoting the greatness that is wikipedia, the pedia that never has errors :P

    In object-oriented programming and software engineering, the visitor design pattern is a way of separating an algorithm from an object structure it operates on. A practical result of this separation is the ability to add new operations to existing object structures without modifying those structures. It is one way to easily follow the open/closed principle. In essence, the visitor allows one to add new virtual functions to a family of classes without modifying the classes themselves; instead, one creates a visitor class that implements all of the appropriate specializations of the virtual function. The visitor takes the instance reference as input, and implements the goal through double dispatch.

提交回复
热议问题