Ruby on Rails patterns - decorator vs presenter

前端 未结 2 902
刺人心
刺人心 2020-12-07 09:27

There is all sorts of talk lately in the Ruby on Rails community about decorators and presenters.

What is the essential difference between the two? If there is, what

2条回答
  •  生来不讨喜
    2020-12-07 09:58

    I suggest you to check this - Exhibit vs Presenter.

    Decorator is a design pattern that is used to extend the functionality of a specific object by wrapping it, without effecting other instances of that object. In general, the decorator pattern is an example of the open/close principle (the class is closed for modifications, but available for extensions).

    Both the exhibit and presenter patterns are a kind of the decorator pattern.

提交回复
热议问题