What's the equivalent name of "procedure" in OOP?

Posted by AeroCross on Programmers See other posts from Programmers or by AeroCross
Published on 2012-09-10T03:23:01Z Indexed on 2012/09/10 3:48 UTC
Read the original article Hit count: 285

In several of my programming courses in the University, my teachers always told me the following:

A function and a procedure are basically the same thing: the only difference is that a function returns a value, and the procedure doesn't.

That means that this:

function sum($a, $b) {
    return $a + $b;
}

... is a function, and this:

function sum($a, $b) {
    echo $a + $b;
}

... is a procedure.

In the same train of thought, I've seen that a method is the equivalent of a function in the OOP world.

That means that this:

class Example {
    function sum($a, $b) {
        return $a + $b;
    }
}

Is a method — but how do you call this?

class Example {
    function sum($a, $b) {
        echo $a + $b;
    }
}

What's the equivalent name, or how do you call a method that doesn't returns anything?

© Programmers or respective owner

Related posts about object-oriented

Related posts about terminology