In a simple example like this, I can omit self for referencing backgroundLayer because it\'s unambiguous which backgroundLayer the backgroundColor is set on.
I'm going to go against the flow and not use self
unless absolutely required.
The reason why is that two of the main reasons to use self
is
self
in a blockself
as a delegateIn both cases, self
will be captured as a strong
reference. This might be what you want, but in many cases, you actually want to use a weak
one.
Therefor, forcing the developer to use self
as an exception and not a rule will make this strong
capture more conscious, and let him reflect on this decision.