Skip to content

Backend Pattern Decorator

Ferris Tseng edited this page Dec 13, 2019 · 5 revisions

[Pattern] Decorator

Description

A decorator allows you to add functionality to a class without changing the behavior of all instances of that class. 1

A decorator is especially good for separating presentation logic from a model.

Location

  • app/decorators

Best Practices

N/A

Tradeoffs

A decorator should primarily be used to separate presentation logic from a model. A concern can also be used to encapsulate, shared business logic, but could pollute the namespace of methods for the model (e.g. a full_name method on the concern could clash with one already on the model).

Resources

Examples in Caseflow

Additional Reading

Related Patterns

Pattern Description
Model Typically used to present a model
Clone this wiki locally