To definition of method of the English Bible says it’s a procedure associated with an object, which can also be called member function. Static methods would be those associated with a class.
Often the terms function, method, procedure, routine and subroutine are used interchangeably to refer to the same thing, but there are some nuances.
I see no difference between procedure, routine and subroutine. They are synonymous with a specific sequence of instructions for a program, which can be invoked from other locations.
Already a function refers to something that returns a value, analogous to mathematics. It would be a set of instructions that returns a value at the end. A function is a procedure, but with this extra return detail.
A method can be a procedure or function, but associated with an object or class. Therefore it can be called "member function".
Practical examples
Procedures are used in languages such as SQL (T-SQL, PL/SQL, etc.) for routines that do not return value. Already functions are used for routines that return values. The same goes for Visual Basic.
Several languages that have first-class functions, such as Javascript, have the function declaration with the reserved word function
.
Object-oriented languages such as Java or C# always use the term method to refer to class procedures.
In PHP, which is object-oriented and functional, the term function is used to refer to routines called directly in the code, while the term method is reserved for the object orientation part, which is nothing more than functions within classes. PHP makes no difference between function that returns value or not.
Completion
Although I have not cited strong references from authors, I think that the content of Wikipedia is coherent and the definitions make general sense on all platforms I know.
I didn’t vote to close but that question seems based on opinions, some languages do as
pascal
make differentiation between function(returns something) and procedure(returns nothing), others do and some understand that the last instruction of a function/procedure is the return. Generally method is associated with object orientation.– rray
Based on the opinions of whom? Of the creators of languages... for me it can be, those are the ones I want: the official definitions.
– Miguel Angelo
Although these definitions vary from language to language, this does not mean that they are opinions.
– utluiz
It is not based on opinions. Concepts exist and are properly postulated.
– Leonel Sanches da Silva
I’ve been doing some research, and I ended up finding one more term: subprocession. I remember that VB6 had
SUB
/END SUB
, that must be it.– Miguel Angelo
Sub
is the equivalent ofProcedure
.– Leonel Sanches da Silva