Ruby on Rails patterns - decorator vs presenter

ε祈祈猫儿з 提交于 2019-11-28 15:17:06

A decorator is more of a "let's add some functionality to this entity". A presenter is more of a "let's build a bridge between the model/backend and view". The presenter pattern has several interpretations.

Decorators are generic/general purpose. Presenters have a narrower range of responsibilities/uses. Decorators are used across domains, presenters are almost always related to view-like functionality.

dpaluy

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!