I'm pretty sure there is a special name for the 'spec' of a function/method. It's a word that refers to
- how many arguments it takes
- the order of arguments
- which arguments are optional
Is there a name for that?
Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up.
Sign up to join this communityI'm pretty sure there is a special name for the 'spec' of a function/method. It's a word that refers to
Is there a name for that?
Usually this is called a type signature.
A type signature includes the function's return type, the number of arguments, the types of arguments, or errors it may pass back.
interface
, or a C/C++ function declaration in a header file (literally called a prototype
).
TL;DR You're probably talking about a function signature (or method signature), part of which is a type signature.
But really depends on what you consider a function "spec". I interpret it as "all the information required for a programmer to call a function". This includes the function name, the parameter type, order, and necessity, probably the return type, and probably even that function's namespace.
But whether or not all those things are required (or even well defined) depends on the language/environment you're using. Also, if you change the definition to "all the information required for a machine to call a function", the spec is likely different1.
Strictly speaking, a function (or method) signature is not a consistent term,2, 3 even within the same language.4, 5, 6, 7 But it's almost certainly the word you're looking for, because it'll be understood by almost any programmer.
public
, static
, etclanguage-agnostic
, the C++ examples are (A) relevant to me and (B) illustrative of the confusion that so often surrounds human terminology
Sep 23, 2015 at 11:43
I believe the term is "contract". It defines the interface and what's expected of caller and callee; however it also covers things like allowed values of parameters which is not something many languages allow to be defined by the function or class definition, so the term "contract" might be broader in meaning than what you meant. I have seen it in several object oriented and Java specific programming books. I'm not sure if it's Java specific but I don't see why would it need to be. Signature is the other commonly used term but I grew to like "contract".