This forum is now read-only. Please use our new forums at discuss.codecademy.com.

1235 points
4f8491aefd881f000300b879_675772913
Submitted by
Samuel Laaja
about 7 years ago

Why are "functions" inside objects called "methods"?

In every method exercise so far, methods are explained as "like functions" or "similar to functions", since they even use the same keyword and syntax. The only difference I have gathered is that they are used inside an object, while functions are not. Is this really the only reason for calling them "methods"?

I'd find it more helpful to just call them "functions inside objects", since that's more descriptive expression.


4 votes

permalink

It's just traditional terminology that has been around for many years in object-oriented programming. You could equally ask why children that are attending school are called students instead of just children. The term method bears more information, because you know immediately that there's some object that this method belongs to (and if the object is obj, you have to call that method using dot notation obj.methodName()), while you can call other functions without prepending an object and a dot to them.

3117 points
Picture
Submitted by
Alex J
about 7 years ago