Consider bringing view decorators / presenters back
We currently do have a lot of business rules hidden inside the views. We may want to improve that by using decorators.
class DeploymentDecorator < ViewDecorator::Base
def formatted_external_url
@decorable.external_url.gsub(/\A.*?:\/\//, '')
end
def some_additional_view_related_method
# do something
end
end
Using decorators can help to:
- improve testability (we will have new objects to test)
- make some business rules explicit (business rules will be moved from views to objects)
- make views much more readable
- decrease number of CE -> EE merge conflicts because we will have more code in separate files
- improve maintainability
- improve security
We have some discussion about that in separate issue, starting here: https://gitlab.com/gitlab-org/gitlab-ce/issues/13484#note_16582304
Related to https://gitlab.com/gitlab-org/gitlab-ce/issues/13484 in general.