Method

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
(New page: Methods are a means of providing classes with behaviour. They consist of four parts: * A textual name * A visibility modifier - This defines the encapsulation of the method: either public...)
 
m (Reverted edits by Ebybymic (Talk); changed back to last version by Matthew Harward)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Methods are a means of providing classes with behaviour. They consist of four parts:
+
Methods are a means of providing objects or classes with behaviour. Methods are usually associated with an object or class; however, certain languages like Dylan do not require this association. In most well known OO programming languages the use of [[Inheritance|inheritance]] allows the mostly class based association to be widened to include subclasses. They usually consist of four parts:
  
 
* A textual name
 
* A textual name
* A visibility modifier - This defines the encapsulation of the method: either public or within some boundary (be it class, object or some other construct)
+
* A visibility modifier - This defines the [[Encapsulation|encapsulation]] of the method: either public or within some boundary (be it class, object or some other construct)
 
* Zero or more parameters - The inputs to the method, either primitives or objects (this can be language specific).
 
* Zero or more parameters - The inputs to the method, either primitives or objects (this can be language specific).
* A returned type - Either no return type (<tt>void</tt>) or returning some primitive (e.g. <tt>float</tt>, <tt>int</tt>) or object.
+
* A returned type - Either no return type (<tt>void</tt>) or returning some primitive (e.g. <tt>float</tt>, <tt>int</tt>) or an object.
  
 
A method may also have other modifiers that change the actions of the method. In Java, an example of this is <tt>synchronized</tt>.
 
A method may also have other modifiers that change the actions of the method. In Java, an example of this is <tt>synchronized</tt>.
Line 11: Line 11:
  
 
== See Also ==
 
== See Also ==
* [[Class vs Object]]
+
* [[Class versus Object]]
 +
 
 +
{{Nomenclature}}
 +
 
 +
[[Category: Nomenclature]]

Latest revision as of 03:23, 25 November 2010

Methods are a means of providing objects or classes with behaviour. Methods are usually associated with an object or class; however, certain languages like Dylan do not require this association. In most well known OO programming languages the use of inheritance allows the mostly class based association to be widened to include subclasses. They usually consist of four parts:

  • A textual name
  • A visibility modifier - This defines the encapsulation of the method: either public or within some boundary (be it class, object or some other construct)
  • Zero or more parameters - The inputs to the method, either primitives or objects (this can be language specific).
  • A returned type - Either no return type (void) or returning some primitive (e.g. float, int) or an object.

A method may also have other modifiers that change the actions of the method. In Java, an example of this is synchronized.

A method is usually considered synonymous with a function or procedure. However, these terms are usually associated with the functional and procedural programming paradigms.

See Also


Personal tools