What is an operation's signature?

Viewed 130

In the Design Patterns book [Gang of Four], Specifying Object Interfaces, page no. 13, it is mentioned that:

Every operation declared by an object specifies...

  1. the operation's name,
  2. the objects it takes as parameters,
  3. and the operation's return value.

Please help me understand why 3) return value is part of the operation/method signature?

In a language such as Java, return type is not part of the method signature. Also is return value part of method signature in java?

1 Answers

Java makes a pedantic distinction between method declaration and method signature in defining methods.

Definition: Two of the components of a method declaration comprise the method signature—the method's name and the parameter types.

The GoF book does not make the same distinction.

signature An operation's signature defines its name, parameters, and return value. (page 361)

So we have two different definitions from two different sources. Signature and declaration are separate in the Java language but synonymous in the GoF book.

Related