Function v Method

I’ve been trying to get my head around the difference between a function and a method.  Part of the trouble in clearing this distinction is that, depending on the language in question, the naming conventions are all over the place.  C never calls anything a method while Java and C# never call anything a function.  Yet each does have both?  Yeah.  A rose by any other name would make people scratch their heads.

In essence, we can rephrase this problem as Classless Functions v Classed Functions.  A Classless Function is a function not associated with a class (nor a struct, C; nor a type, Go) while a Classed Function is a function tied to a class.  To call a classless, one merely calls the function by name, while to call a classed, one must call it using dot notation (class.function).

A Classless Function may be called a function or a static method and a Classed Function may be called a member function or a method.  See how this adds to the confusion?  No wonder developers get paid extra.

This question page have several answers which attempt to dive into this problem:

What’s the difference between a method and a function?


Leave a Reply

Your email address will not be published. Required fields are marked *