wnagrodzki / iOSProgrammingGuidelines

2 stars 0 forks source link

Type vs instance methods #4

Closed wnagrodzki closed 6 years ago

wnagrodzki commented 6 years ago

If a method is independent from the instance state it should be declared as a static method, or class method if it is designed to be overridden by a subclass.

pwetrifork commented 6 years ago

It should probably also be noted that static is to be preferred over class.

wnagrodzki commented 6 years ago

@pwetrifork I adjusted the text.

wnagrodzki commented 6 years ago

If a method is independent of instance state it should be declared as type method, preferably by using static keyword (or class in case when the method is designed to be overridden in a subclass).

Instance method independent from instance state would give false impression that it is in fact dependent on instance state. We aim to avoid confusion.

@pwetrifork @Moskacz I have rephrased whole paragraph. Do you think it is good enough to be called final?

pwetrifork commented 6 years ago

This is to avoid methods giving a false impression that they are dependent on the instance state while in fact they are not