Content deleted Content added
No edit summary |
No edit summary |
||
Line 1:
Used mainly in [[object-oriented programming]], the term '''method''' refers to a [[subprogram (programming)|piece of code]] that is exclusively associated either with a [[class (computer science)|class]] (called '''class methods''' or '''static methods''') or with an [[object (computer science)|object]] (called '''instance methods'''). Like a procedure in [[procedural programming languages]], a method usually consists of a sequence of [[statement (programming)|statements]] to perform an action, a set of input [[parameter (programming)|parameters]] to parameterize those actions, and possibly an output value (called '''return value''') of some kind. The purpose of methods is to provide a mechanism for accessing (for both reading and writing) the private data stored in an object or a class.
A method should preserve the [[invariant|class invariants]]
==Scope==
Whereas a [[C programming language|C]] [[programmer]] might push a value onto a [[stack_(software)|Stack]] data-structure by calling:
stackPush(&myStack, value);
|