Object-oriented – What’s the equivalent name of “procedure” in OOP

object-orientedterminology

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?

Best Answer

Method as a concept encompasses both the function and procedure notations.