wnagrodzki / iOSProgrammingGuidelines

2 stars 0 forks source link

Property vs method #5

Open wnagrodzki opened 6 years ago

wnagrodzki commented 6 years ago
pwetrifork commented 6 years ago

I think this needs to be more specific about “work to be done”. Swift API design guidelines suggest using algorithmic complexity, i.e. they imply that computed properties that aren’t O(1) should be documented as such.

wnagrodzki commented 6 years ago

In general, methods represent actions and properties represent data. Properties are meant to be used like fields, meaning that properties should not be computationally complex or produce side effects. When it does not violate the following guidelines, consider using a property, rather than a method. Source MSDN