Method (computer programming)

A method in object-oriented programming (OOP) is a procedure associated with an object, and generally also a message.Methods also provide the interface that other classes use to access and modify the properties of an object; this is known as encapsulation.If one views the receiving object as the first parameter in any method then overriding is just a special case of overloading where the selection is based only on the first argument.The following simple Java example illustrates the difference: Accessor methods are used to read the data values of an object.Manager methods are used to initialize and destroy objects of a class, e.g. constructors and destructors.Indeed, in many ways the object-oriented approach is simply the logical extension of previous paradigms such as abstract data types and structured programming.Destruction in most languages does not allow destructor method arguments nor return values.But in some languages such as the Common Lisp Object System (CLOS) the meta-model allows the developer to dynamically alter the object model at run time: e.g., to create new classes, redefine the class hierarchy, modify properties, etc.Static methods are called "static" because they are resolved at compile time based on the class they are called on and not dynamically as in the case with instance methods, which are resolved polymorphically based on the runtime type of the object.Due to the design requirements to add the object-oriented paradigm on to an existing procedural language, message passing in C++ has some unique capabilities and terminologies.
object-oriented programmingprocedureobjectmessageinterfacepropertiesclass-based programminginstancesmethod overridingencapsulationoverloadingAccessor methodsabstraction layermodularitybalancerevisionsdatabaseabstract data typesstructured programmingConstructor (computer science)constructorconstructionDestructor (computer science)DestructorDestructiongarbage-collectedPythonfinalizerssignatureimplementation bodyinterfacesmeta-modelMeta-model protocolsCommon Lisp Object System (CLOS)object modelStatic member functionstatic variablescompile timedefine or redefine operator symbolsvirtual functionsoverriddenderived classesdynamic dispatchpolymorphismProperty (programming)Remote method invocationSubroutineMartin, Robert C.