Skip to content

Commit edd6f67

Browse files
author
Guido Marucci Blas
committed
Merge pull request #1 from fedelcar/patch-1
Extract view logic from controller rationale
2 parents 2b4522f + 3abc813 commit edd6f67

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

rules/separate-view-logic.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
## Extract view logic from controller
22

3+
### Description
4+
5+
Instead of having all the outlets and styling logic for the view in its View Controller, we extract all this logic to a different ```swift UIView``` subclass. This makes controllers smaller and is a much better way of dividing responsibilites.
6+
7+
38
### Rationale
49

5-
TODO
10+
A very common problem as applications grow over time is that controllers often end up being quite large and handling a lot of responsibilities. One approach we take at Wolox to avoid this is using the MVVM architecture, thus moving most of the presentation logic out of the View Controller. However, when the view itself is rcomplex, the controller ends up having outlet references to many interface elements and then having to bind them and update them throughout its logic. Therefore, we prefer to have a UIView subclass that has all these references and handles the view logic, together with the styling of the elements. The View Controller still has to pass the elements that it gets from its View Model, but as it only has a reference to the view, it saves it from having to style and manage all these interface elements.
611

712
### Example
813

0 commit comments

Comments
 (0)