There is kind of a debate on this topic, some say that there is a crucial difference between them and others say there is no difference, in this article we'll examine the two points of view and their arguments in order to have a conclusion at the end.
The reasons why we would say that they are different could be :
- a method is an object while a function is independent of any object or class, for example in java and c# there are no functions, while in c there are only functions, to simplify this we can say that:
- a function is a feature or functionality
- a method is one way of doing something (therefore it has different approaches..)
- functions are defined outside of a class, while methods are defined inside a class...
the reasons why we would say they are the same are :
-
in the OO world, the two are commonly used to mean the same thing, From a pure Math and CS perspective, a function will always return the same result when called with the same arguments ( f(x,y) = (x + y) ). A method, on the other hand, is typically associated with an instance of a class. Again though, most modern OO languages no longer use the term "function" for the most part. Many static methods can be quite like functions, as they typically have no state
-
'method' is the object-oriented word for 'function'. That's pretty much all there is to it (ie., no real difference).
0 Comments