RailsCasts Pro episodes are now free!

Learn more or hide this

Conrad Taylor's Profile

GitHub User: conradwt

Site: www.conradtaylor.com

Comments by Conrad Taylor


Presenter design pattern aka presenter refactoring is a way of simplifying controller logic by extracting it out into its own class which has one or more methods. Thus, making it easier to test controller logic by usually transforming each assigned instance variable in a controller action into its own method within the presenter class. Anytime you see a controller action which has many instances variables, it needs to be refactored to use a presenter. Decorator design pattern is a way of adding additional behaviors or responsibilities to an object dynamically without subclassing. The decorator pattern is a very good example of the Open-Close-Principle (OCP) which states that an class is closed to modification but open to extension. In short, the decorator pattern is a composing operation whereas the presenter pattern is a decomposing operation.