What is the best approach when using methods/ Functions

Viewed 49

First for all I know this a subjective question and may be it will be closed. However I have a confusion in class methods and Free functions.

As class methods we all are aware and as per maintain code quality it is right approach. So what is the importance of using free functions how it improves the code quality.

For Example:

In iOS we are create a function in a class and call it like:

 let str = self.myFunctionName() /// This is defined in same class

And when we are use free functions we can call like this:

let str = myFreeFunctionName() /// This defined in some other class, so it can be used in other classes.

Which will be more efficient from both.

1 Answers
Related